diff options
author | Keith Whitwell <[email protected]> | 2006-09-07 18:28:35 +0000 |
---|---|---|
committer | Keith Whitwell <[email protected]> | 2006-09-07 18:28:35 +0000 |
commit | c26f36c830cc6df1093a145eb43645f535004eb7 (patch) | |
tree | 61f366a672e19a1f5970b4448817647acb9bfcf4 /src/mesa/main/mm.c | |
parent | e48db4430fe850cbaf55f2ea5c142ecea3c2a48b (diff) |
Add some asserts, fix some not-quite-bugs.
Diffstat (limited to 'src/mesa/main/mm.c')
-rw-r--r-- | src/mesa/main/mm.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/mesa/main/mm.c b/src/mesa/main/mm.c index d080d6db1b8..7a657dc3cad 100644 --- a/src/mesa/main/mm.c +++ b/src/mesa/main/mm.c @@ -43,7 +43,7 @@ mmDumpMemInfo(const struct mem_block *heap) fprintf(stderr, "\nFree list:\n"); for(p = heap->next_free; p != heap; p = p->next_free) { - fprintf(stderr, " Offset:%08x, Size:%08x, %c%c\n",p->ofs,p->size, + fprintf(stderr, " FREE Offset:%08x, Size:%08x, %c%c\n",p->ofs,p->size, p->free ? 'F':'.', p->reserved ? 'R':'.'); } @@ -85,7 +85,7 @@ mmInit(int ofs, int size) block->size = size; block->free = 1; - return (struct mem_block *)heap; + return heap; } @@ -120,7 +120,7 @@ SliceBlock(struct mem_block *p, p = newblock; } - /* break right, also [p, newblock, p->next], then p = newblock*/ + /* break right, also [p, newblock, p->next] */ if (size < p->size) { newblock = (struct mem_block*) _mesa_calloc(sizeof(struct mem_block)); if (!newblock) @@ -151,6 +151,9 @@ SliceBlock(struct mem_block *p, p->next_free->prev_free = p->prev_free; p->prev_free->next_free = p->next_free; + p->next_free = 0; + p->prev_free = 0; + p->reserved = reserved; return p; } @@ -182,6 +185,7 @@ mmAllocMem(struct mem_block *heap, int size, int align2, int startSearch) if (p == heap) return NULL; + assert(p->free); p = SliceBlock(p,startofs,size,0,mask+1); return p; @@ -211,6 +215,8 @@ Join2Blocks(struct mem_block *p) if (p->free && p->next->free) { struct mem_block *q = p->next; + + assert(p->ofs + p->size == q->ofs); p->size += q->size; p->next = q->next; @@ -228,6 +234,8 @@ Join2Blocks(struct mem_block *p) int mmFreeMem(struct mem_block *b) { + struct mem_block *heap = b->heap; + if (!b) return 0; @@ -247,7 +255,7 @@ mmFreeMem(struct mem_block *b) b->prev_free->next_free = b; Join2Blocks(b); - if (b->prev) + if (b->prev != b->heap) Join2Blocks(b->prev); return 0; |