*
*/
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+
#include "mm.h"
if (!size)
return NULL;
- heap = (struct mem_block *) _mesa_calloc(sizeof(struct mem_block));
+ heap = calloc(1, sizeof(struct mem_block));
if (!heap)
return NULL;
- block = (struct mem_block *) _mesa_calloc(sizeof(struct mem_block));
+ block = calloc(1, sizeof(struct mem_block));
if (!block) {
- _mesa_free(heap);
+ free(heap);
return NULL;
}
/* break left [p, newblock, p->next], then p = newblock */
if (startofs > p->ofs) {
- newblock = (struct mem_block*) _mesa_calloc(sizeof(struct mem_block));
+ newblock = calloc(1, sizeof(struct mem_block));
if (!newblock)
return NULL;
newblock->ofs = startofs;
/* break right, also [p, newblock, p->next] */
if (size < p->size) {
- newblock = (struct mem_block*) _mesa_calloc(sizeof(struct mem_block));
+ newblock = calloc(1, sizeof(struct mem_block));
if (!newblock)
return NULL;
newblock->ofs = startofs + size;
}
-static INLINE int
+static inline int
Join2Blocks(struct mem_block *p)
{
/* XXX there should be some assertions here */
q->next_free->prev_free = q->prev_free;
q->prev_free->next_free = q->next_free;
- _mesa_free(q);
+ free(q);
return 1;
}
return 0;
for (p = heap->next; p != heap; ) {
struct mem_block *next = p->next;
- _mesa_free(p);
+ free(p);
p = next;
}
- _mesa_free(heap);
+ free(heap);
}