Skip to content

Commit 14f23f6

Browse files
committed
Avoid useless allocation on mmap'd file access
1 parent 799ebcb commit 14f23f6

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

lib/buffer.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ mapcache_buffer *mapcache_buffer_create(size_t initialStorage, apr_pool_t* pool)
5757
mapcache_buffer *buffer = apr_pcalloc(pool, sizeof(mapcache_buffer));
5858
if(!buffer) return NULL;
5959
buffer->pool = pool;
60-
if(initialStorage <=0) initialStorage = 1;
6160
buffer->avail = initialStorage;
6261
if(buffer->avail) {
6362
buffer->buf = malloc(buffer->avail);

lib/cache_disk.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,10 +435,10 @@ static int _mapcache_cache_disk_get(mapcache_context *ctx, mapcache_cache *pcach
435435
* i.e. normally only once.
436436
*/
437437
tile->mtime = finfo.mtime;
438-
tile->encoded_data = mapcache_buffer_create(size,ctx->pool);
439438

440439
#ifndef NOMMAP
441440

441+
tile->encoded_data = mapcache_buffer_create(0,ctx->pool);
442442
rv = apr_mmap_create(&tilemmap,f,0,finfo.size,APR_MMAP_READ,ctx->pool);
443443
if(rv != APR_SUCCESS) {
444444
char errmsg[120];
@@ -448,6 +448,7 @@ static int _mapcache_cache_disk_get(mapcache_context *ctx, mapcache_cache *pcach
448448
tile->encoded_data->buf = tilemmap->mm;
449449
tile->encoded_data->size = tile->encoded_data->avail = finfo.size;
450450
#else
451+
tile->encoded_data = mapcache_buffer_create(size,ctx->pool);
451452
//manually add the data to our buffer
452453
apr_file_read(f,(void*)tile->encoded_data->buf,&size);
453454
tile->encoded_data->size = size;

0 commit comments

Comments
 (0)