NMEM: Update API to use size_t for sizes
authorAdam Dickmeiss <adam@indexdata.dk>
Thu, 14 Jan 2010 08:52:20 +0000 (09:52 +0100)
committerAdam Dickmeiss <adam@indexdata.dk>
Thu, 14 Jan 2010 11:25:09 +0000 (12:25 +0100)
include/yaz/nmem.h
src/nmem.c

index fb7910c..2b86006 100644 (file)
@@ -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
  */
 /** \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
 
 /** \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
  */
     \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
 
 
 YAZ_END_CDECL
 
index 93988b5..4b6d0a4 100644 (file)
@@ -10,8 +10,6 @@
  * This is a simple and fairly wasteful little module for nibble memory
  * allocation. Evemtually we'll put in something better.
  *
  * 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 <config.h>
  */
 #if HAVE_CONFIG_H
 #include <config.h>
@@ -38,7 +36,7 @@ struct nmem_block
 
 struct nmem_control
 {
 
 struct nmem_control
 {
-    int total;
+    size_t total;
     struct nmem_block *blocks;
     struct nmem_control *next;
 };
     struct nmem_block *blocks;
     struct nmem_control *next;
 };
@@ -111,7 +109,7 @@ void nmem_reset(NMEM n)
     n->total = 0;
 }
 
     n->total = 0;
 }
 
-void *nmem_malloc(NMEM n, int size)
+void *nmem_malloc(NMEM n, size_t size)
 {
     struct nmem_block *p;
     char *r;
 {
     struct nmem_block *p;
     char *r;
@@ -135,7 +133,7 @@ void *nmem_malloc(NMEM n, int size)
     return r;
 }
 
     return r;
 }
 
-int nmem_total(NMEM n)
+size_t nmem_total(NMEM n)
 {
     return n->total;
 }
 {
     return n->total;
 }