diff --git a/core/Makefile b/core/Makefile index a258e45..69a58dd 100644 --- a/core/Makefile +++ b/core/Makefile @@ -1,4 +1,10 @@ -OBJS = pc_core.o + + + +OBJS = pc_core.o \ + pc_mem.o + + LIB = pc_lib.a all: $(LIB) diff --git a/core/pc_api.h b/core/pc_api.h index c0f82dc..e8f8dc7 100644 --- a/core/pc_api.h +++ b/core/pc_api.h @@ -7,6 +7,9 @@ * ***********************************************************************/ +#include +#include + /********************************************************************** * DATA STRUCTURES */ @@ -108,17 +111,37 @@ typedef struct PCDIMENSION *dims; } PCSCHEMA; - +/* Global functions for memory/logging handlers. */ +typedef void* (*pc_allocator)(size_t size); +typedef void* (*pc_reallocator)(void *mem, size_t size); +typedef void (*pc_deallocator)(void *mem); +typedef void (*pc_message_handler)(const char *string, va_list ap); /********************************************************************** -* FUNTION PROTOTYPES +* FUNCTION PROTOTYPES */ +/* Memory management and logging */ +void* pcalloc(size_t size); +void* pcrealloc(void* mem, size_t size); +void pcfree(void* mem); +void pcerror(const char *fmt, ...); +void pcinfo(const char *fmt, ...); +void pcwarn(const char *fmt, ...); + +/* Set allocators and messaging */ +void pc_set_handlers(pc_allocator allocator, pc_reallocator reallocator, + pc_deallocator deallocator, pc_message_handler error_handler, + pc_message_handler info_handler, pc_message_handler warning_handler); + +/* Use system allocators and messaging */ +void pc_install_default_handlers(void); + + /* Utility */ void pc_schema_free(PCSCHEMA *pcf); PCSCHEMA* pc_schema_construct(const char *xmlstr); - /* Accessors */ int8 pc_point_get_int8 (const PCPOINT *pt, uint32 dim); uint8 pc_point_get_uint8 (const PCPOINT *pt, uint32 dim); diff --git a/core/pc_c.h b/core/pc_c.h index af5d789..7c57163 100644 --- a/core/pc_c.h +++ b/core/pc_c.h @@ -15,4 +15,4 @@ typedef long int int64; #endif #ifndef HAVE_UINT64 typedef unsigned long int uint64; -#endif +#endif \ No newline at end of file diff --git a/core/pc_core.c b/core/pc_core.c index 2855b83..6a790c9 100644 --- a/core/pc_core.c +++ b/core/pc_core.c @@ -9,3 +9,5 @@ #include "pc_c.h" #include "pc_api.h" + +