add .gitignore
[tedtools.git] / tmalloc.h
index cc10c33..89648de 100644 (file)
--- a/tmalloc.h
+++ b/tmalloc.h
@@ -46,7 +46,7 @@ int clrspace(char *buf);
 
 /* fast allocate */
 
-#define CNTXCHUNK      (1024*1024)
+#define CNTXCHUNK      (64*1024)
 
 typedef struct MemoryChunk {
        size_t  size;
@@ -85,5 +85,20 @@ void mcfree(void * ptr);
 char * mcstrdup(MemoryContext *cntx, char * src);
 char * mcnstrdup(MemoryContext *cntx, char *src, int len);
 
+typedef void* (*MemAlloc)(void *ptr, size_t size);
+
+typedef struct {
+    char            *buf;
+       char            *ptr;
+       u_int32_t       len;
+       MemoryContext   *mc;
+       MemAlloc                memalloc;
+} StringBuffer;
+
+StringBuffer* initStringBuffer(StringBuffer* state, int initsize);
+StringBuffer* initStringBufferMC(StringBuffer* state, MemoryContext *mc, int initsize);
+StringBuffer* initStringBufferMA(StringBuffer* state, MemAlloc memalloc, int initsize);
+StringBuffer* appendStringBuffer( StringBuffer *state, char *string, int stringlen);
+StringBuffer* printStringBuffer( StringBuffer *state, const char *format, ...);
 
 #endif