util: Rename from u_* to util_* while we're at it.
[mesa.git] / src / gallium / auxiliary / util / u_mm.c
index 0f51dd59777b7c0184fc2d825245caee99f4333b..4b75d4ba1d0155f9129663ab3b557a1cdb2458d2 100644 (file)
 
 
 #include "pipe/p_compiler.h"
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
 
 #include "util/u_memory.h"
 #include "util/u_mm.h"
 
 
 void
-mmDumpMemInfo(const struct mem_block *heap)
+u_mmDumpMemInfo(const struct mem_block *heap)
 {
-   debug_printf("Memory heap %p:\n", (void *)heap);
+   debug_printf("Memory heap %p:\n", (void *) heap);
    if (heap == 0) {
       debug_printf("  heap == 0\n");
-   } else {
+   }
+   else {
       const struct mem_block *p;
 
-      for(p = heap->next; p != heap; p = p->next) {
-        debug_printf("  Offset:%08x, Size:%08x, %c%c\n",p->ofs,p->size,
-                p->free ? 'F':'.',
-                p->reserved ? 'R':'.');
+      for (p = heap->next; p != heap; p = p->next) {
+        debug_printf("  Offset:%08x, Size:%08x, %c%c\n", p->ofs, p->size,
+                      p->free ? 'F':'.',
+                      p->reserved ? 'R':'.');
       }
 
       debug_printf("\nFree list:\n");
 
-      for(p = heap->next_free; p != heap; p = p->next_free) {
-        debug_printf(" FREE Offset:%08x, Size:%08x, %c%c\n",p->ofs,p->size,
-                p->free ? 'F':'.',
-                p->reserved ? 'R':'.');
+      for (p = heap->next_free; p != heap; p = p->next_free) {
+        debug_printf(" FREE Offset:%08x, Size:%08x, %c%c\n", p->ofs, p->size,
+                      p->free ? 'F':'.',
+                      p->reserved ? 'R':'.');
       }
 
    }
    debug_printf("End of memory blocks\n");
 }
 
+
 struct mem_block *
-mmInit(int ofs, int size)
+u_mmInit(int ofs, int size)
 {
    struct mem_block *heap, *block;
   
@@ -165,13 +167,17 @@ SliceBlock(struct mem_block *p,
 
 
 struct mem_block *
-mmAllocMem(struct mem_block *heap, int size, int align2, int startSearch)
+u_mmAllocMem(struct mem_block *heap, int size, int align2, int startSearch)
 {
    struct mem_block *p;
    const int mask = (1 << align2)-1;
    int startofs = 0;
    int endofs;
 
+   assert(size >= 0);
+   assert(align2 >= 0);
+   assert(align2 <= 12); /* sanity check, 2^12 (4KB) enough? */
+
    if (!heap || align2 < 0 || size <= 0)
       return NULL;
 
@@ -198,7 +204,7 @@ mmAllocMem(struct mem_block *heap, int size, int align2, int startSearch)
 
 
 struct mem_block *
-mmFindBlock(struct mem_block *heap, int start)
+u_mmFindBlock(struct mem_block *heap, int start)
 {
    struct mem_block *p;
 
@@ -237,7 +243,7 @@ Join2Blocks(struct mem_block *p)
 }
 
 int
-mmFreeMem(struct mem_block *b)
+u_mmFreeMem(struct mem_block *b)
 {
    if (!b)
       return 0;
@@ -266,7 +272,7 @@ mmFreeMem(struct mem_block *b)
 
 
 void
-mmDestroy(struct mem_block *heap)
+u_mmDestroy(struct mem_block *heap)
 {
    struct mem_block *p;