From: Adam Dickmeiss Date: Thu, 14 Jan 2010 08:52:20 +0000 (+0100) Subject: NMEM: Update API to use size_t for sizes X-Git-Tag: v4.0.0~46 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=4e50d9461c89fb538b1826f9cecf4475deaeed3b;p=yaz-moved-to-github.git NMEM: Update API to use size_t for sizes --- diff --git a/include/yaz/nmem.h b/include/yaz/nmem.h index fb7910c..2b86006 100644 --- a/include/yaz/nmem.h +++ b/include/yaz/nmem.h @@ -78,7 +78,7 @@ YAZ_EXPORT void nmem_reset(NMEM n); /** \brief returns size in bytes of memory for NMEM handle \returns number of bytes */ -YAZ_EXPORT int nmem_total(NMEM n); +YAZ_EXPORT size_t nmem_total(NMEM n); /** \brief allocates string on NMEM handle (similar strdup) \param mem HNEM handle @@ -156,7 +156,7 @@ YAZ_EXPORT void nmem_destroy(NMEM n); \param size number of bytes to be allocated \returns pointer to allocated memory */ -YAZ_EXPORT void *nmem_malloc(NMEM n, int size); +YAZ_EXPORT void *nmem_malloc(NMEM n, size_t size); YAZ_END_CDECL diff --git a/src/nmem.c b/src/nmem.c index 93988b5..4b6d0a4 100644 --- a/src/nmem.c +++ b/src/nmem.c @@ -10,8 +10,6 @@ * This is a simple and fairly wasteful little module for nibble memory * allocation. Evemtually we'll put in something better. * - * FIXME - it also has some semaphore stuff, and stuff to handle errno. - * These should be moved to some other place! */ #if HAVE_CONFIG_H #include @@ -38,7 +36,7 @@ struct nmem_block struct nmem_control { - int total; + size_t total; struct nmem_block *blocks; struct nmem_control *next; }; @@ -111,7 +109,7 @@ void nmem_reset(NMEM n) n->total = 0; } -void *nmem_malloc(NMEM n, int size) +void *nmem_malloc(NMEM n, size_t size) { struct nmem_block *p; char *r; @@ -135,7 +133,7 @@ void *nmem_malloc(NMEM n, int size) return r; } -int nmem_total(NMEM n) +size_t nmem_total(NMEM n) { return n->total; }