]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - gmqcc.h
Dump old tests, test suite will take over .. It isn't activly used, just killing...
[xonotic/gmqcc.git] / gmqcc.h
diff --git a/gmqcc.h b/gmqcc.h
index 5e34c949419c2c7f1a0d95e8ce5025fd1109d21a..e32943d5e35baa08c1e450004a86e7eaddf62efd 100644 (file)
--- a/gmqcc.h
+++ b/gmqcc.h
@@ -193,6 +193,7 @@ FILE *util_fopen(const char *filename, const char *mode);
 
 void *util_memory_a      (unsigned int, unsigned int, const char *);
 void  util_memory_d      (void       *, unsigned int, const char *);
+void *util_memory_r      (void       *, unsigned int, unsigned int, const char *);
 void  util_meminfo       ();
 
 bool  util_strupper      (const char *);
@@ -214,11 +215,13 @@ uint16_t util_crc16(uint16_t crc, const char *data, size_t len);
 uint32_t util_crc32(uint32_t crc, const char *data, size_t len);
 
 #ifdef NOTRACK
-#    define mem_a(x) malloc(x)
-#    define mem_d(x) free  (x)
+#    define mem_a(x)   malloc(x)
+#    define mem_d(x)   free  (x)
+#    define mem_r(x,y) realloc((x),(y))
 #else
-#    define mem_a(x) util_memory_a((x), __LINE__, __FILE__)
-#    define mem_d(x) util_memory_d((x), __LINE__, __FILE__)
+#    define mem_a(x)   util_memory_a((x), __LINE__, __FILE__)
+#    define mem_d(x)   util_memory_d((x), __LINE__, __FILE__)
+#    define mem_r(x,y) util_memory_r((x), (y), __LINE__, __FILE__)
 #endif
 
 /*
@@ -692,17 +695,20 @@ bool GMQCC_WARN Tself##_##mem##_find(Tself *self, Twhat obj, size_t *idx) \
 bool GMQCC_WARN Tself##_##mem##_append(Tself *s, Twhat *p, size_t c) \
 {                                                                    \
     Twhat *reall;                                                    \
+    size_t oldalloc;                                                 \
     if (s->mem##_count+c > s->mem##_alloc) {                         \
         if (!s->mem##_alloc) {                                       \
             s->mem##_alloc = c < 16 ? 16 : c;                        \
             s->mem = (Twhat*)mem_a(sizeof(Twhat) * s->mem##_alloc);  \
         } else {                                                     \
+            oldalloc = s->mem##_alloc;                               \
             s->mem##_alloc *= 2;                                     \
             if (s->mem##_count+c >= s->mem##_alloc) {                \
                 s->mem##_alloc = s->mem##_count+c;                   \
             }                                                        \
             reall = (Twhat*)mem_a(sizeof(Twhat) * s->mem##_alloc);   \
             if (!reall) {                                            \
+                s->mem##_alloc = oldalloc;                           \
                 return false;                                        \
             }                                                        \
             memcpy(reall, s->mem, sizeof(Twhat) * s->mem##_count);   \
@@ -736,6 +742,7 @@ bool GMQCC_WARN Tself##_##mem##_resize(Tself *s, size_t c)       \
         memcpy(reall, s->mem, sizeof(Twhat) * c);                \
         mem_d(s->mem);                                           \
         s->mem = reall;                                          \
+        s->mem##_alloc = c;                                      \
     }                                                            \
     return true;                                                 \
 }
@@ -1008,6 +1015,7 @@ extern bool        opts_dump;
 extern bool        opts_werror;
 extern bool        opts_forcecrc;
 extern uint16_t    opts_forced_crc;
+extern bool        opts_pp_only;
 
 /*===================================================================*/
 #define OPTS_FLAG(i) (!! (opts_flags[(i)/32] & (1<< ((i)%32))))