summaryrefslogtreecommitdiff
path: root/src/common/utils.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/utils.h')
-rw-r--r--src/common/utils.h49
1 files changed, 14 insertions, 35 deletions
diff --git a/src/common/utils.h b/src/common/utils.h
index 10c10ad..961d960 100644
--- a/src/common/utils.h
+++ b/src/common/utils.h
@@ -1,39 +1,18 @@
-#include "mt_rand.h"
-
-#ifndef NULL
-#define NULL (void *)0
-#endif
-
-#define LOWER(c) (((c)>='A' && (c) <= 'Z') ? ((c)+('a'-'A')) : (c))
-#define UPPER(c) (((c)>='a' && (c) <= 'z') ? ((c)+('A'-'a')) : (c) )
-
-/* strcasecmp -> stricmp -> str_cmp */
-
-#ifdef LCCWIN32
-int strcasecmp (const char *arg1, const char *arg2);
-int strncasecmp (const char *arg1, const char *arg2, int n);
-void str_upper (char *name);
-void str_lower (char *name);
-char *rindex (char *str, char c);
-#endif
-
-void dump (unsigned char *buffer, int num);
-
-#define CREATE(result, type, number) do {\
- if ((number) * sizeof(type) <= 0) \
- printf("SYSERR: Zero bytes or less requested at %s:%d.\n", __FILE__, __LINE__); \
+#ifndef UTILS_H
+#define UTILS_H
+/*
+Notes about memory allocation in tmwAthena:
+There used to be 3 sources of allocation: these macros,
+a{C,M,Re}alloc in common/malloc.{h,c}, and direct calls.
+I deleted malloc.{h,c} because it was redundant;
+future calls should either use this or depend on the coming segfault.
+*/
+# define CREATE(result, type, number) \
if (!((result) = (type *) calloc ((number), sizeof(type)))) \
- { perror("SYSERR: malloc failure"); abort(); } } while(0)
+ { perror("SYSERR: malloc failure"); abort(); } else (void)0
-#define RECREATE(result,type,number) do {\
+# define RECREATE(result,type,number) \
if (!((result) = (type *) realloc ((result), sizeof(type) * (number))))\
- { printf("SYSERR: realloc failure"); abort(); } } while(0)
+ { perror("SYSERR: realloc failure"); abort(); } else (void)0
-/*
- * ModuloRand and ModuloPlusRand. These macros are used to replace the
- * vast number of calls to rand()%mod ..
- * MRAND(10), returns 0-9.
- * MPRAND(5,10) returns 5-14.
- */
-#define MRAND(mod) (int) (mt_random() % (mod))
-#define MPRAND(add, mod) add + MRAND(mod)
+#endif //UTILS_H