Add tor_realloc to mirror tor_malloc

svn:r582
This commit is contained in:
Nick Mathewson 2003-10-14 01:11:42 +00:00
parent 6115813de3
commit 77be56fbdd
2 changed files with 12 additions and 0 deletions

View File

@ -25,6 +25,17 @@ void *tor_malloc(size_t size) {
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);

View File

@ -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);