diff options
-rw-r--r-- | common/shmalloc.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/common/shmalloc.c b/common/shmalloc.c index 3ada36feaa..d00470a2fe 100644 --- a/common/shmalloc.c +++ b/common/shmalloc.c @@ -210,7 +210,7 @@ static int do_acquire(int size, struct shm_buffer **dest_ptr) pfb = free_buf_chain; while (pfb) { - if ((pfb->buffer_size > size) && + if ((pfb->buffer_size >= size) && ((pfb->buffer_size - size) < headroom)) { /* this is a new candidate. */ headroom = pfb->buffer_size - size; @@ -299,6 +299,8 @@ int shared_mem_size(void) } mutex_unlock(&shmem_lock); + /* Leave room for shmem header */ + max_available -= sizeof(struct shm_buffer); return max_available; } |