pool.c calls renamed so they can me used by MAMEUI and MESS (no whatsnew needed)

This commit is contained in:
Miodrag Milanovic 2010-01-19 15:42:30 +00:00
parent 409add88bb
commit 50b784c99e
2 changed files with 24 additions and 25 deletions

View file

@ -40,7 +40,6 @@
#include <stdarg.h> #include <stdarg.h>
#include <stddef.h> #include <stddef.h>
#include <stdlib.h> #include <stdlib.h>
#include "pool.h" #include "pool.h"
#include "coreutil.h" #include "coreutil.h"
@ -165,7 +164,7 @@ INLINE objtype_entry *get_object_type(object_pool *pool, object_type type)
pool_alloc - allocates a new memory pool pool_alloc - allocates a new memory pool
-------------------------------------------------*/ -------------------------------------------------*/
object_pool *pool_alloc(void (*fail)(const char *message)) object_pool *pool_alloc_lib(void (*fail)(const char *message))
{ {
object_pool *pool; object_pool *pool;
@ -252,7 +251,7 @@ void pool_clear(object_pool *pool)
contained memory blocks contained memory blocks
-------------------------------------------------*/ -------------------------------------------------*/
void pool_free(object_pool *pool) void pool_free_lib(object_pool *pool)
{ {
object_entry_block *block, *nextblock; object_entry_block *block, *nextblock;
objtype_entry *type, *nexttype; objtype_entry *type, *nexttype;
@ -610,37 +609,37 @@ int test_memory_pools(void)
int i; int i;
has_memory_error = FALSE; has_memory_error = FALSE;
pool = pool_alloc(memory_error); pool = pool_alloc_lib(memory_error);
memset(ptrs, 0, sizeof(ptrs)); memset(ptrs, 0, sizeof(ptrs));
ptrs[0] = pool_malloc(pool, 50); ptrs[0] = pool_malloc_lib(pool, 50);
ptrs[1] = pool_malloc(pool, 100); ptrs[1] = pool_malloc_lib(pool, 100);
ptrs[0] = pool_realloc(pool, ptrs[0], 150); ptrs[0] = pool_realloc_lib(pool, ptrs[0], 150);
ptrs[1] = pool_realloc(pool, ptrs[1], 200); ptrs[1] = pool_realloc_lib(pool, ptrs[1], 200);
ptrs[2] = pool_malloc(pool, 250); ptrs[2] = pool_malloc_lib(pool, 250);
ptrs[3] = pool_malloc(pool, 300); ptrs[3] = pool_malloc_lib(pool, 300);
ptrs[0] = pool_realloc(pool, ptrs[0], 350); ptrs[0] = pool_realloc_lib(pool, ptrs[0], 350);
ptrs[1] = pool_realloc(pool, ptrs[1], 400); ptrs[1] = pool_realloc_lib(pool, ptrs[1], 400);
ptrs[2] = pool_realloc(pool, ptrs[2], 450); ptrs[2] = pool_realloc_lib(pool, ptrs[2], 450);
ptrs[3] = pool_realloc(pool, ptrs[3], 500); ptrs[3] = pool_realloc_lib(pool, ptrs[3], 500);
ptrs[0] = pool_realloc(pool, ptrs[0], 0); ptrs[0] = pool_realloc_lib(pool, ptrs[0], 0);
ptrs[1] = pool_realloc(pool, ptrs[1], 0); ptrs[1] = pool_realloc_lib(pool, ptrs[1], 0);
ptrs[2] = pool_realloc(pool, ptrs[2], 550); ptrs[2] = pool_realloc_lib(pool, ptrs[2], 550);
ptrs[3] = pool_realloc(pool, ptrs[3], 600); ptrs[3] = pool_realloc_lib(pool, ptrs[3], 600);
/* some heavier stress tests */ /* some heavier stress tests */
for (i = 0; i < 512; i++) for (i = 0; i < 512; i++)
{ {
ptrs[i % ARRAY_LENGTH(ptrs)] = pool_realloc(pool, ptrs[i % ARRAY_LENGTH(ptrs)] = pool_realloc_lib(pool,
ptrs[i % ARRAY_LENGTH(ptrs)], rand() % 1000); ptrs[i % ARRAY_LENGTH(ptrs)], rand() % 1000);
} }
pool_free(pool); pool_free_lib(pool);
return has_memory_error; return has_memory_error;
} }

View file

@ -48,9 +48,9 @@
***************************************************************************/ ***************************************************************************/
/* helper macros for memory pools that pass file/line number */ /* helper macros for memory pools that pass file/line number */
#define pool_malloc(pool, size) pool_malloc_file_line((pool), (size), __FILE__, __LINE__) #define pool_malloc_lib(pool, size) pool_malloc_file_line((pool), (size), __FILE__, __LINE__)
#define pool_realloc(pool, ptr, size) pool_realloc_file_line((pool), (ptr), (size), __FILE__, __LINE__) #define pool_realloc_lib(pool, ptr, size) pool_realloc_file_line((pool), (ptr), (size), __FILE__, __LINE__)
#define pool_strdup(pool, size) pool_strdup_file_line((pool), (size), __FILE__, __LINE__) #define pool_strdup_lib(pool, size) pool_strdup_file_line((pool), (size), __FILE__, __LINE__)
/* macro to define a 4-character type for a pool */ /* macro to define a 4-character type for a pool */
#define OBJECT_TYPE(a,b,c,d) (((a) << 24) | ((b) << 16) | ((c) << 8) | (d)) #define OBJECT_TYPE(a,b,c,d) (((a) << 24) | ((b) << 16) | ((c) << 8) | (d))
@ -84,7 +84,7 @@ typedef struct _object_pool_iterator object_pool_iterator;
/* ----- object pool management ----- */ /* ----- object pool management ----- */
/* allocate a new object pool */ /* allocate a new object pool */
object_pool *pool_alloc(void (*fail)(const char *message)); object_pool *pool_alloc_lib(void (*fail)(const char *message));
/* register a new object type; returns TRUE if the type already existed and was overridden */ /* register a new object type; returns TRUE if the type already existed and was overridden */
void pool_type_register(object_pool *pool, object_type type, const char *friendly, void (*destructor)(void *, size_t)); void pool_type_register(object_pool *pool, object_type type, const char *friendly, void (*destructor)(void *, size_t));
@ -93,7 +93,7 @@ void pool_type_register(object_pool *pool, object_type type, const char *friendl
void pool_clear(object_pool *pool); void pool_clear(object_pool *pool);
/* free an object pool, including all allocated objects */ /* free an object pool, including all allocated objects */
void pool_free(object_pool *pool); void pool_free_lib(object_pool *pool);