mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-22 14:21:25 +02:00
MINOR: memory: remove macros
We finally get rid of the macros and use usual memory management functions directly.
This commit is contained in:
parent
56d260916f
commit
b781dbede3
@ -41,28 +41,6 @@
|
|||||||
# define CONFIG_HAP_MEM_OPTIM
|
# define CONFIG_HAP_MEM_OPTIM
|
||||||
#endif /* CONFIG_HAP_NO_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
|
/* CONFIG_HAP_INLINE_FD_SET
|
||||||
* This makes use of inline FD_* macros instead of calling equivalent
|
* This makes use of inline FD_* macros instead of calling equivalent
|
||||||
* functions. Benchmarks on a Pentium-M show that using functions is
|
* functions. Benchmarks on a Pentium-M show that using functions is
|
||||||
|
10
src/memory.c
10
src/memory.c
@ -81,7 +81,7 @@ struct pool_head *create_pool(char *name, unsigned int size, unsigned int flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!pool) {
|
if (!pool) {
|
||||||
pool = CALLOC(1, sizeof(*pool));
|
pool = calloc(1, sizeof(*pool));
|
||||||
if (!pool)
|
if (!pool)
|
||||||
return NULL;
|
return NULL;
|
||||||
if (name)
|
if (name)
|
||||||
@ -114,7 +114,7 @@ void *pool_refill_alloc(struct pool_head *pool, unsigned int avail)
|
|||||||
if (pool->limit && pool->allocated >= pool->limit)
|
if (pool->limit && pool->allocated >= pool->limit)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
ptr = MALLOC(pool->size + POOL_EXTRA);
|
ptr = malloc(pool->size + POOL_EXTRA);
|
||||||
if (!ptr) {
|
if (!ptr) {
|
||||||
pool->failed++;
|
pool->failed++;
|
||||||
if (failed)
|
if (failed)
|
||||||
@ -151,7 +151,7 @@ void pool_flush2(struct pool_head *pool)
|
|||||||
temp = next;
|
temp = next;
|
||||||
next = *POOL_LINK(pool, temp);
|
next = *POOL_LINK(pool, temp);
|
||||||
pool->allocated--;
|
pool->allocated--;
|
||||||
FREE(temp);
|
free(temp);
|
||||||
}
|
}
|
||||||
pool->free_list = next;
|
pool->free_list = next;
|
||||||
|
|
||||||
@ -180,7 +180,7 @@ void pool_gc2()
|
|||||||
temp = next;
|
temp = next;
|
||||||
next = *POOL_LINK(entry, temp);
|
next = *POOL_LINK(entry, temp);
|
||||||
entry->allocated--;
|
entry->allocated--;
|
||||||
FREE(temp);
|
free(temp);
|
||||||
}
|
}
|
||||||
entry->free_list = next;
|
entry->free_list = next;
|
||||||
}
|
}
|
||||||
@ -204,7 +204,7 @@ void *pool_destroy2(struct pool_head *pool)
|
|||||||
pool->users--;
|
pool->users--;
|
||||||
if (!pool->users) {
|
if (!pool->users) {
|
||||||
LIST_DEL(&pool->list);
|
LIST_DEL(&pool->list);
|
||||||
FREE(pool);
|
free(pool);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user