Skip to content

Commit

Permalink
Merge "EGL: do not use sparse files for shader"
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean-Baptiste Queru authored and android code review committed Aug 20, 2012
2 parents db1597a + a30cc7d commit 6f89ebd
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions opengl/libs/EGL/egl_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,19 +241,11 @@ void egl_cache_t::saveBlobCacheLocked() {
}

size_t fileSize = headerSize + cacheSize;
if (ftruncate(fd, fileSize) == -1) {
ALOGE("error setting cache file size: %s (%d)", strerror(errno),
errno);
close(fd);
unlink(fname);
return;
}

uint8_t* buf = reinterpret_cast<uint8_t*>(mmap(NULL, fileSize,
PROT_WRITE, MAP_SHARED, fd, 0));
if (buf == MAP_FAILED) {
ALOGE("error mmaping cache file: %s (%d)", strerror(errno),
errno);
uint8_t* buf = new uint8_t [fileSize];
if (!buf) {
ALOGE("error allocating buffer for cache contents: %s (%d)",
strerror(errno), errno);
close(fd);
unlink(fname);
return;
Expand All @@ -264,7 +256,7 @@ void egl_cache_t::saveBlobCacheLocked() {
if (err != OK) {
ALOGE("error writing cache contents: %s (%d)", strerror(-err),
-err);
munmap(buf, fileSize);
delete [] buf;
close(fd);
unlink(fname);
return;
Expand All @@ -275,7 +267,16 @@ void egl_cache_t::saveBlobCacheLocked() {
uint32_t* crc = reinterpret_cast<uint32_t*>(buf + 4);
*crc = crc32c(buf + headerSize, cacheSize);

munmap(buf, fileSize);
if (write(fd, buf, fileSize) == -1) {
ALOGE("error writing cache file: %s (%d)", strerror(errno),
errno);
delete [] buf;
close(fd);
unlink(fname);
return;
}

delete [] buf;
fchmod(fd, S_IRUSR);
close(fd);
}
Expand Down

0 comments on commit 6f89ebd

Please sign in to comment.