fehler63
authorMatthias Braun <matze@braunis.de>
Tue, 7 Aug 2007 12:53:00 +0000 (12:53 +0000)
committerMatthias Braun <matze@braunis.de>
Tue, 7 Aug 2007 12:53:00 +0000 (12:53 +0000)
[r15488]

ir/be/test/fehler63.c [new file with mode: 0644]

diff --git a/ir/be/test/fehler63.c b/ir/be/test/fehler63.c
new file mode 100644 (file)
index 0000000..f5075a3
--- /dev/null
@@ -0,0 +1,63 @@
+#include <string.h>
+#include <stdlib.h>
+
+#define ZONEID  0x1d4a11
+
+typedef struct memblock_s {
+    int     size;           // including the header and possibly tiny fragments
+    int     tag;            // a tag of 0 is a free block
+    struct memblock_s       *next, *prev;
+    int     id;             // should be ZONEID
+#ifdef ZONE_DEBUG
+    zonedebug_t d;
+#endif
+} memblock_t;
+
+typedef struct {
+    int     size;           // total bytes malloced, including header
+    int     used;           // total bytes used
+    memblock_t  blocklist;  // start / end cap for linked list
+    memblock_t  *rover;
+} memzone_t;
+
+typedef char byte;
+
+static void Z_ClearZone( memzone_t *zone, int size ) {
+    memblock_t  *block;
+
+    // set the entire zone to one free block
+
+    zone->blocklist.next = zone->blocklist.prev = block =
+        (memblock_t *)( (byte *)zone + sizeof(memzone_t) );
+#if 0
+    zone->blocklist.tag = 1;    // in use block
+    zone->blocklist.id = 0;
+    zone->blocklist.size = 0;
+    zone->rover = block;
+    zone->size = size;
+    zone->used = 0;
+#endif
+
+    block->prev = block->next = &zone->blocklist;
+    block->tag = 0;         // free block
+    block->id = ZONEID;
+    block->size = size - sizeof(memzone_t);
+}
+
+void Com_InitSmallZoneMemory( void ) {
+       int s_smallZoneTotal = 512 * 1024;
+       // bk001205 - was malloc
+       memzone_t *smallzone = calloc( s_smallZoneTotal, 1 );
+       if ( !smallzone ) {
+               abort();
+       }
+       Z_ClearZone( smallzone, s_smallZoneTotal );
+
+       return;
+}
+
+int main(void)
+{
+       Com_InitSmallZoneMemory();
+       return 0;
+}