add a tor_malloc_zero wrapper: tor_malloc and memset 0

svn:r836
This commit is contained in:
Roger Dingledine 2003-11-18 08:20:09 +00:00
parent a3e39b0ceb
commit ec02f83f94
2 changed files with 7 additions and 0 deletions

View File

@ -25,6 +25,12 @@ void *tor_malloc(size_t size) {
return result; 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 *tor_realloc(void *ptr, size_t size) {
void *result; void *result;

View File

@ -33,6 +33,7 @@
#endif #endif
void *tor_malloc(size_t size); void *tor_malloc(size_t size);
void *tor_malloc_zero(size_t size);
void *tor_realloc(void *ptr, size_t size); void *tor_realloc(void *ptr, size_t size);
char *tor_strdup(const char *s); char *tor_strdup(const char *s);
#define tor_free(p) do {if(p) {free(p); (p)=NULL;}} while(0) #define tor_free(p) do {if(p) {free(p); (p)=NULL;}} while(0)