projects
/
convexer.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
model view prototype
[convexer.git]
/
cxr
/
cxr_mem.h
diff --git
a/cxr/cxr_mem.h
b/cxr/cxr_mem.h
index 437831489ce2c741a810b00401730467abf9b38d..38e7a3f1bd7a1d4cff8d88f14da6e9dbc226614c 100644
(file)
--- a/
cxr/cxr_mem.h
+++ b/
cxr/cxr_mem.h
@@
-1,3
+1,12
@@
+#ifndef CXR_MEM_H
+#define CXR_MEM_H
+
+#include <string.h>
+#include <stdlib.h>
+
+#include "cxr_types.h"
+#include "cxr_math.h"
+
typedef struct cxr_abuffer cxr_abuffer;
struct cxr_abuffer
typedef struct cxr_abuffer cxr_abuffer;
struct cxr_abuffer
@@
-28,7
+37,8
@@
static void *__cxr_ab_ptr( struct cxr_abuffer *buffer, u32 index
#ifdef CXR_DEBUG_ALLOCATORS
if( index >= buffer->capacity || index < 0 )
{
#ifdef CXR_DEBUG_ALLOCATORS
if( index >= buffer->capacity || index < 0 )
{
- printf( "index out of capactity (%d /: [0->%d (cap)]) (%s)\n", index, buffer->capacity, debug_str );
+ printf( "index out of capactity (%d /: [0->%d (cap)]) (%s)\n", index,
+ buffer->capacity, debug_str );
exit(1);
}
#endif
exit(1);
}
#endif
@@
-84,10
+94,13
@@
static void cxr_ab_push( struct cxr_abuffer *buffer, void *em )
static void cxr_ab_init( struct cxr_abuffer *buffer, u32 esize, u32 cap )
{
buffer->esize = esize;
static void cxr_ab_init( struct cxr_abuffer *buffer, u32 esize, u32 cap )
{
buffer->esize = esize;
- buffer->capacity = c
xr_max(1,cap)
;
+ buffer->capacity = c
ap
;
buffer->count = 0;
buffer->count = 0;
- buffer->arr = malloc( buffer->esize*buffer->capacity );
+ if( cap )
+ buffer->arr = malloc( buffer->esize*buffer->capacity );
+ else
+ buffer->arr = NULL;
}
static void cxr_ab_clear( struct cxr_abuffer *buffer )
}
static void cxr_ab_clear( struct cxr_abuffer *buffer )
@@
-99,3
+112,5
@@
static void cxr_ab_free( struct cxr_abuffer *buffer )
{
free( buffer->arr );
}
{
free( buffer->arr );
}
+
+#endif /* CXR_TYPES_H */