aboutsummaryrefslogtreecommitdiff
path: root/src/globals.h
diff options
context:
space:
mode:
authorFranklin Wei <git@fwei.tk>2016-01-24 16:58:59 -0500
committerFranklin Wei <git@fwei.tk>2016-01-24 16:58:59 -0500
commitb346e948cb167c18efc33f32f0e7cfb21050fc96 (patch)
tree2a6989023690021c15999ce8fc3fefdca3ab7d83 /src/globals.h
parente2c2a9878a0fb55923fbd77db1f73085013aa36c (diff)
downloadnetcosm-b346e948cb167c18efc33f32f0e7cfb21050fc96.zip
netcosm-b346e948cb167c18efc33f32f0e7cfb21050fc96.tar.gz
netcosm-b346e948cb167c18efc33f32f0e7cfb21050fc96.tar.bz2
netcosm-b346e948cb167c18efc33f32f0e7cfb21050fc96.tar.xz
objects partially implemented, fixes some bugs
Diffstat (limited to 'src/globals.h')
-rw-r--r--src/globals.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/globals.h b/src/globals.h
index 1daac8e..9944996 100644
--- a/src/globals.h
+++ b/src/globals.h
@@ -28,6 +28,7 @@
#include <arpa/inet.h>
#include <arpa/telnet.h>
#include <assert.h>
+#include <bsd/stdlib.h> // for arc4random
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
@@ -46,6 +47,7 @@
#include <sys/ipc.h>
#include <sys/mman.h>
#include <sys/socket.h>
+#include <sys/time.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <time.h>
@@ -90,3 +92,24 @@
#else
#define debugf(fmt,...) /* nop */
#endif
+
+#if 0
+extern bool are_child;
+
+static void *logged_malloc(const char *func, int line, size_t sz)
+{
+ if(are_child)
+ debugf("%s:%d mallocs %d bytes\n", func, line, sz);
+ return malloc(sz);
+}
+
+static void *logged_calloc(const char *func, int line, size_t x, size_t y)
+{
+ if(are_child)
+ debugf("%s:%d callocs %dx%d bytes\n", func, line, x,y);
+ return calloc(x,y);
+}
+
+#define malloc(x) logged_malloc(__func__, __LINE__, x)
+#define calloc(x,y) logged_calloc(__func__, __LINE__, x,y)
+#endif