]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: memory: remove macros
authorDavid Carlier <devnexen@gmail.com>
Fri, 21 Jul 2017 07:44:40 +0000 (08:44 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 21 Jul 2017 07:54:03 +0000 (09:54 +0200)
We finally get rid of the macros and use usual memory management
functions directly.

include/common/config.h
src/memory.c

index 27b8f14e9afde5045951bd8aa7d8d3b9bb74b3d3..f5d290f603aed14625718d541e4ba70700754888 100644 (file)
 #  define CONFIG_HAP_MEM_OPTIM
 #endif /* CONFIG_HAP_NO_MEM_OPTIM */
 
-/* CONFIG_HAP_MALLOC / CONFIG_HAP_CALLOC / CONFIG_HAP_FREE
- * This macro allows to replace the malloc function with another one.
- */
-#ifdef CONFIG_HAP_MALLOC
-#define MALLOC CONFIG_HAP_MALLOC
-#else
-#define MALLOC malloc
-#endif
-
-#ifdef CONFIG_HAP_CALLOC
-#define CALLOC CONFIG_HAP_CALLOC
-#else
-#define CALLOC calloc
-#endif
-
-#ifdef CONFIG_HAP_FREE
-#define FREE   CONFIG_HAP_FREE
-#else
-#define FREE   free
-#endif
-
-
 /* CONFIG_HAP_INLINE_FD_SET
  * This makes use of inline FD_* macros instead of calling equivalent
  * functions. Benchmarks on a Pentium-M show that using functions is
index c1db4ff9496ea5e24aa28316611855e41826f9af..9f8396d5b554b30b9f1a054f3a3c0cfd0a960868 100644 (file)
@@ -81,7 +81,7 @@ struct pool_head *create_pool(char *name, unsigned int size, unsigned int flags)
        }
 
        if (!pool) {
-               pool = CALLOC(1, sizeof(*pool));
+               pool = calloc(1, sizeof(*pool));
                if (!pool)
                        return NULL;
                if (name)
@@ -114,7 +114,7 @@ void *pool_refill_alloc(struct pool_head *pool, unsigned int avail)
                if (pool->limit && pool->allocated >= pool->limit)
                        return NULL;
 
-               ptr = MALLOC(pool->size + POOL_EXTRA);
+               ptr = malloc(pool->size + POOL_EXTRA);
                if (!ptr) {
                        pool->failed++;
                        if (failed)
@@ -151,7 +151,7 @@ void pool_flush2(struct pool_head *pool)
                temp = next;
                next = *POOL_LINK(pool, temp);
                pool->allocated--;
-               FREE(temp);
+               free(temp);
        }
        pool->free_list = next;
 
@@ -180,7 +180,7 @@ void pool_gc2()
                        temp = next;
                        next = *POOL_LINK(entry, temp);
                        entry->allocated--;
-                       FREE(temp);
+                       free(temp);
                }
                entry->free_list = next;
        }
@@ -204,7 +204,7 @@ void *pool_destroy2(struct pool_head *pool)
                pool->users--;
                if (!pool->users) {
                        LIST_DEL(&pool->list);
-                       FREE(pool);
+                       free(pool);
                }
        }
        return NULL;