[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] Add tor_realloc to mirror tor_malloc



Update of /home/or/cvsroot/src/common
In directory moria.mit.edu:/tmp/cvs-serv17536/src/common

Modified Files:
	util.c util.h 
Log Message:
Add tor_realloc to mirror tor_malloc

Index: util.c
===================================================================
RCS file: /home/or/cvsroot/src/common/util.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- util.c	10 Oct 2003 01:48:03 -0000	1.28
+++ util.c	14 Oct 2003 01:11:42 -0000	1.29
@@ -25,6 +25,17 @@
   return result;
 }
 
+void *tor_realloc(void *ptr, size_t size) {
+  void *result;
+  
+  result = realloc(ptr, size);
+  if (!result) {
+    log_fn(LOG_ERR, "Out of memory. Dying.");
+    exit(1);
+  }
+  return result;
+}
+
 char *tor_strdup(const char *s) {
   char *dup;
   assert(s);

Index: util.h
===================================================================
RCS file: /home/or/cvsroot/src/common/util.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- util.h	7 Oct 2003 16:29:57 -0000	1.17
+++ util.h	14 Oct 2003 01:11:42 -0000	1.18
@@ -34,6 +34,7 @@
 
 #define xfree(p) do {if(p) {free(p); (p)=NULL;}} while(0) /* XXX use everywhere? */
 void *tor_malloc(size_t size);
+void *tor_realloc(void *ptr, size_t size);
 char *tor_strdup(const char *s);
 void tor_gettimeofday(struct timeval *timeval);