projects
/
tedtools.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
49bc5b6
)
Add resetMemoryContext()
author
teodor
<teodor>
Thu, 18 Sep 2008 09:45:55 +0000
(09:45 +0000)
committer
teodor
<teodor>
Thu, 18 Sep 2008 09:45:55 +0000
(09:45 +0000)
tmalloc.c
patch
|
blob
|
history
tmalloc.h
patch
|
blob
|
history
diff --git
a/tmalloc.c
b/tmalloc.c
index
9f96ab9
..
c03a7ff
100644
(file)
--- a/
tmalloc.c
+++ b/
tmalloc.c
@@
-161,6
+161,25
@@
freeMemoryContext(MemoryContext *cntx) {
}
}
}
}
+void
+resetMemoryContext(MemoryContext *cntx) {
+ MemoryChunk *chunk, *chunkptr;
+
+ while( cntx ) {
+ chunkptr = cntx->chunk;
+ chunkptr->freesize = chunkptr->size;
+ chunkptr = chunkptr->next;
+ cntx->chunk->next = NULL;
+
+ while( chunkptr ) {
+ chunk=chunkptr->next;
+ tfree(chunkptr);
+ chunkptr=chunk;
+ }
+ cntx=cntx->child;
+ }
+}
+
void*
mcalloc(MemoryContext *cntx, size_t size) {
MemoryChunk *chunk = cntx->chunk;
void*
mcalloc(MemoryContext *cntx, size_t size) {
MemoryChunk *chunk = cntx->chunk;
diff --git
a/tmalloc.h
b/tmalloc.h
index
67069eb
..
4cb0a0b
100644
(file)
--- a/
tmalloc.h
+++ b/
tmalloc.h
@@
-77,6
+77,7
@@
typedef struct {
MemoryContext *allocMemoryContext(MemoryContext* parent, int flags);
void freeMemoryContext(MemoryContext* cntx);
MemoryContext *allocMemoryContext(MemoryContext* parent, int flags);
void freeMemoryContext(MemoryContext* cntx);
+void resetMemoryContext(MemoryContext* cntx);
void* mcalloc(MemoryContext *cntx, size_t size);
void* mc0alloc(MemoryContext *cntx, size_t size);
void* mcrealloc(void * ptr, size_t size);
void* mcalloc(MemoryContext *cntx, size_t size);
void* mc0alloc(MemoryContext *cntx, size_t size);
void* mcrealloc(void * ptr, size_t size);