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

[or-cvs] add a tor_malloc_zero wrapper: tor_malloc and memset 0



Update of /home/or/cvsroot/src/common
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/common

Modified Files:
	util.c util.h 
Log Message:
add a tor_malloc_zero wrapper: tor_malloc and memset 0


Index: util.c
===================================================================
RCS file: /home/or/cvsroot/src/common/util.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- util.c	13 Nov 2003 06:45:59 -0000	1.40
+++ util.c	18 Nov 2003 08:20:09 -0000	1.41
@@ -25,6 +25,12 @@
   return result;
 }
 
+void *tor_malloc_zero(size_t size) {
+  void *result = tor_malloc(size);
+  memset(result, 0, size);
+  return result;
+}
+
 void *tor_realloc(void *ptr, size_t size) {
   void *result;
   

Index: util.h
===================================================================
RCS file: /home/or/cvsroot/src/common/util.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- util.h	12 Nov 2003 19:34:19 -0000	1.22
+++ util.h	18 Nov 2003 08:20:09 -0000	1.23
@@ -33,6 +33,7 @@
 #endif
 
 void *tor_malloc(size_t size);
+void *tor_malloc_zero(size_t size);
 void *tor_realloc(void *ptr, size_t size);
 char *tor_strdup(const char *s);
 #define tor_free(p) do {if(p) {free(p); (p)=NULL;}} while(0)