src/server/ucx/mempool.c

changeset 31
280250e45ba6
parent 25
5dee29c7c530
child 71
069c152f6272
--- a/src/server/ucx/mempool.c	Thu May 24 12:51:52 2012 +0200
+++ b/src/server/ucx/mempool.c	Fri May 25 18:16:24 2012 +0200
@@ -50,7 +50,7 @@
     }
 }
 
-void *ucx_mempool_malloc(UcxMempool *pool, size_t n) {   
+void *ucx_mempool_malloc(UcxMempool *pool, size_t n) {
     ucx_memchunk *mem = (ucx_memchunk*)malloc(sizeof(ucx_destructor) + n);
     if (mem == NULL) return NULL;
 
@@ -65,7 +65,7 @@
     return &mem->c;
 }
 
-void *ucx_mempool_calloc(UcxMempool *pool, size_t nelem, size_t elsize) {  
+void *ucx_mempool_calloc(UcxMempool *pool, size_t nelem, size_t elsize) {
     void *ptr = ucx_mempool_malloc(pool, nelem*elsize);
     if(ptr == NULL) {
         return NULL;
@@ -74,21 +74,21 @@
     return ptr;
 }
 
-void *ucx_mempool_realloc(UcxMempool *pool, void *ptr, size_t n) { 
-    void *mem = ((char*)ptr) - sizeof(ucx_destructor);
+void *ucx_mempool_realloc(UcxMempool *pool, void *ptr, size_t n) {
+    char *mem = ((char*)ptr) - sizeof(ucx_destructor);
     char *newm = (char*) realloc(mem, n + sizeof(ucx_destructor));
     if (newm == NULL) return NULL;
     if (mem != newm) {
         for(int i=0;i<pool->ndata;i++) {
             if(pool->data[i] == mem) {
                 pool->data[i] = newm;
-                return ((char*) newm) + sizeof(ucx_destructor);
+                return newm + sizeof(ucx_destructor);
             }
         }
-        fprintf(stderr, "FATAL: %8x not in mpool %8x\n", mem, pool);
+        fprintf(stderr, "FATAL: %8x not in mpool %8x\n", ptr, pool);
         exit(1);
     } else {
-        return ((char*) newm) + sizeof(ucx_destructor);
+        return newm + sizeof(ucx_destructor);
     }
 }
 

mercurial