-/*
- * On windows systems where we're not compiling with MING32 we need a
- * little extra help on dependinces for implementing our own dirent.h
- * in fs.c.
- */
-#if defined(_WIN32) && !defined(__MINGW32__)
-# define _WIN32_LEAN_AND_MEAN
-# include <windows.h>
-# include <io.h>
-# include <fcntl.h>
-
- struct dirent {
- long d_ino;
- unsigned short d_reclen;
- unsigned short d_namlen;
- char d_name[FILENAME_MAX];
- };
-
- typedef struct {
- struct _finddata_t dd_dta;
- struct dirent dd_dir;
- long dd_handle;
- int dd_stat;
- char dd_name[1];
- } DIR;
- /*
- * Visual studio also lacks S_ISDIR for sys/stat.h, so we emulate this as well
- * which is not hard at all.
- */
-# ifdef S_ISDIR
-# undef S_ISDIR
-# endif /*! S_ISDIR */
-# define S_ISDIR(X) ((X)&_S_IFDIR)
-#else
-# include <dirent.h>
-#endif /*! _WIN32 && !defined(__MINGW32__) */
-
-/*===================================================================*/
-/*=========================== stat.c ================================*/
-/*===================================================================*/
-typedef struct {
- size_t key;
- size_t value;
-} stat_size_entry_t, **stat_size_table_t;
-
-void stat_info();
-
-char *stat_mem_strdup (const char *, size_t, const char *, bool);
-void *stat_mem_reallocate(void *, size_t, size_t, const char *);
-void stat_mem_deallocate(void *);
-void *stat_mem_allocate (size_t, size_t, const char *);
-
-stat_size_table_t stat_size_new();
-stat_size_entry_t *stat_size_get(stat_size_table_t, size_t);
-void stat_size_del(stat_size_table_t);
-void stat_size_put(stat_size_table_t, size_t, size_t);
-
-/* getters for hashtable: */
-stat_size_table_t *stat_size_hashtables_get();
-uint64_t *stat_type_hashtables_get();
-uint64_t *stat_used_hashtables_get();
-stat_size_table_t *stat_hashtables_init();
-
-#define mem_a(SIZE) stat_mem_allocate ((SIZE), __LINE__, __FILE__)
-#define mem_d(PTRN) stat_mem_deallocate((void*)(PTRN))
-#define mem_r(PTRN, SIZE) stat_mem_reallocate((void*)(PTRN), (SIZE), __LINE__, __FILE__)
-#define mem_af(SIZE, FILE, LINE) stat_mem_allocate ((SIZE), (LINE), (FILE))
-
-/* TODO: rename to mem variations */
-#define util_strdup(SRC) stat_mem_strdup((char*)(SRC), __LINE__, __FILE__, false)
-#define util_strdupe(SRC) stat_mem_strdup((char*)(SRC), __LINE__, __FILE__, true)
-
-/*===================================================================*/
-/*=========================== util.c ================================*/
-/*===================================================================*/
-bool util_filexists (const char *);
-bool util_strupper (const char *);
-bool util_strdigit (const char *);
-void util_debug (const char *, const char *, ...);
-void util_endianswap (void *, size_t, unsigned int);
-
-size_t util_strtocmd (const char *, char *, size_t);
-size_t util_strtononcmd (const char *, char *, size_t);
+#define GMQCC_ARRAY_COUNT(X) (sizeof(X) / sizeof((X)[0]))
+
+/* stat.c */
+char *stat_mem_strdup(const char *, bool);
+
+#define mem_a(SIZE) malloc(SIZE)
+#define mem_d(PTRN) free((void*)PTRN)
+#define mem_r(PTRN, SIZE) realloc((void*)PTRN, SIZE)
+
+#define util_strdup(SRC) stat_mem_strdup((char*)(SRC), false)
+#define util_strdupe(SRC) stat_mem_strdup((char*)(SRC), true)
+
+#define util_isalpha(a) ((((unsigned)(a)|32)-'a') < 26)
+#define util_isdigit(a) (((unsigned)(a)-'0') < 10)
+#define util_islower(a) (((unsigned)(a)-'a') < 26)
+#define util_isupper(a) (((unsigned)(a)-'A') < 26)
+#define util_isprint(a) (((unsigned)(a)-0x20) < 0x5F)
+#define util_isspace(a) (((a) >= 9 && (a) <= 13) || (a) == ' ')
+
+bool util_strupper(const char *);
+bool util_strdigit(const char *);
+
+void util_endianswap(void *, size_t, unsigned int);
+
+size_t util_strtocmd (const char *, char *, size_t);
+size_t util_strtononcmd (const char *, char *, size_t);
+size_t util_optimizationtostr(const char *, char *, size_t);