X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fmain%2Fmm.c;h=473e90fc2d5be879f13eb2ad7346ccb5494b60d2;hb=faccbaf3faf9a7cdcda3e4032fafd0f6064459bd;hp=fb7809ed221427622d676474431d515842f7f893;hpb=3ccbde627edb420071b08a830dd58ed5daf82ffa;p=mesa.git diff --git a/src/mesa/main/mm.c b/src/mesa/main/mm.c index fb7809ed221..473e90fc2d5 100644 --- a/src/mesa/main/mm.c +++ b/src/mesa/main/mm.c @@ -22,6 +22,11 @@ * */ +#include +#include +#include + +#include "compiler.h" #include "mm.h" @@ -53,20 +58,20 @@ mmDumpMemInfo(const struct mem_block *heap) } struct mem_block * -mmInit(unsigned int ofs, int size) +mmInit(unsigned ofs, unsigned size) { struct mem_block *heap, *block; - if (size <= 0) + 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; } @@ -91,14 +96,14 @@ mmInit(unsigned int ofs, int size) static struct mem_block * SliceBlock(struct mem_block *p, - unsigned int startofs, int size, - int reserved, int alignment) + unsigned startofs, unsigned size, + unsigned reserved, unsigned alignment) { struct mem_block *newblock; /* 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; @@ -122,7 +127,7 @@ SliceBlock(struct mem_block *p, /* 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; @@ -160,14 +165,14 @@ SliceBlock(struct mem_block *p, struct mem_block * -mmAllocMem(struct mem_block *heap, int size, int align2, int startSearch) +mmAllocMem(struct mem_block *heap, unsigned size, unsigned align2, unsigned startSearch) { struct mem_block *p; - const int mask = (1 << align2)-1; - unsigned int startofs = 0; - unsigned int endofs; + const unsigned mask = (1 << align2)-1; + unsigned startofs = 0; + unsigned endofs; - if (!heap || align2 < 0 || size <= 0) + if (!heap || !size) return NULL; for (p = heap->next_free; p != heap; p = p->next_free) { @@ -193,7 +198,7 @@ mmAllocMem(struct mem_block *heap, int size, int align2, int startSearch) struct mem_block * -mmFindBlock(struct mem_block *heap, int start) +mmFindBlock(struct mem_block *heap, unsigned start) { struct mem_block *p; @@ -206,7 +211,7 @@ mmFindBlock(struct mem_block *heap, int start) } -static INLINE int +static inline int Join2Blocks(struct mem_block *p) { /* XXX there should be some assertions here */ @@ -225,7 +230,7 @@ Join2Blocks(struct mem_block *p) 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; @@ -270,9 +275,9 @@ mmDestroy(struct mem_block *heap) for (p = heap->next; p != heap; ) { struct mem_block *next = p->next; - _mesa_free(p); + free(p); p = next; } - _mesa_free(heap); + free(heap); }