]> git.tdb.fi Git - gldbg.git/blobdiff - source/enums.c
Replace per-file license notices with License.txt
[gldbg.git] / source / enums.c
index 4875aa366aec8e5dbd6ab7997e1b04f117f6f4b5..b0b5793c38dc7b33bf3b9d5bdbded200d51c1b60 100644 (file)
@@ -1,13 +1,8 @@
-/* $Id$
-
-This file is part of gldbg
-Copyright © 2009  Mikko Rasa, Mikkosoft Productions
-Distributed under the GPL
-*/
-
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include "enums.h"
+#include "tmpalloc.h"
 
 typedef struct sEnumInfo
 {
@@ -16,22 +11,7 @@ typedef struct sEnumInfo
        const char *name;
 } EnumInfo;
 
-#include "enums.table"
-
-char *buffer = 0;
-unsigned buf_pos = 0;
-
-static char *buf_reserve(unsigned size)
-{
-       char *ptr;
-       if(!buffer)
-               buffer = (char *)malloc(2048);
-       if(buf_pos+size>2048)
-               buf_pos = 0;
-       ptr = buffer+buf_pos;
-       buf_pos += size;
-       return ptr;
-}
+#include "gensrc/enums.table"
 
 const char *describe_enum(GLenum value, const char *categ)
 {
@@ -64,7 +44,7 @@ const char *describe_enum(GLenum value, const char *categ)
        if(enums[high].value==value)
                return enums[high].name;
 
-       ptr = buf_reserve(20);
+       ptr = (char *)tmpalloc(20);
        snprintf(ptr, 20, "GLenum(0x%X)", value);
        return ptr;
 }
@@ -72,7 +52,7 @@ const char *describe_enum(GLenum value, const char *categ)
 const char *describe_bitfield(int mask, const char *categ)
 {
        int bit;
-       char *buf = buf_reserve(200);
+       char *buf = (char *)tmpalloc(200);
        char *ptr = buf;
 
        for(bit=1; bit; bit<<=1)