From: Adam Dickmeiss Date: Tue, 7 Jun 2005 19:47:31 +0000 (+0000) Subject: Use size_t for NMEM's get_block. Change space-left check to X-Git-Tag: YAZ.2.1.8~1 X-Git-Url: http://sru.miketaylor.org.uk/cgi-bin?a=commitdiff_plain;h=862b4ea8c948d499192abd1fd420000bec94d249;p=yaz-moved-to-github.git Use size_t for NMEM's get_block. Change space-left check to avoid signed/unsigned-ness problems. --- diff --git a/src/nmem.c b/src/nmem.c index f1fcb1a..484836c 100644 --- a/src/nmem.c +++ b/src/nmem.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2005, Index Data ApS * See the file LICENSE for details. * - * $Id: nmem.c,v 1.17 2005-06-03 20:33:13 adam Exp $ + * $Id: nmem.c,v 1.18 2005-06-07 19:47:31 adam Exp $ */ /** @@ -211,12 +211,12 @@ void nmem_print_list_l (int level) /* * acquire a block with a minimum of size free bytes. */ -static nmem_block *get_block(int size) +static nmem_block *get_block(size_t size) { nmem_block *r, *l; if (log_level) - yaz_log (log_level, "nmem get_block size=%d", size); + yaz_log (log_level, "nmem get_block size=%ld", (long) size); for (r = freelist, l = 0; r; l = r, r = r->next) if (r->size >= size) @@ -288,7 +288,7 @@ void *nmem_malloc(NMEM n, int size) #endif NMEM_ENTER; p = n->blocks; - if (!p || p->size - p->top < size) + if (!p || p->size < size + p->top) { p = get_block(size); p->next = n->blocks;