|
Tor 0.4.9.3-alpha-dev
|
Wrappers for C malloc code, and replacements for items that may be missing. More...
#include "orconfig.h"#include <stdlib.h>#include <string.h>#include "lib/testsupport/testsupport.h"#include "lib/malloc/malloc.h"#include "lib/cc/torint.h"#include "lib/err/torerr.h"Go to the source code of this file.
Macros | |
| #define | UTIL_MALLOC_PRIVATE |
| #define | SQRT_SIZE_MAX_P1 (((size_t)1) << (sizeof(size_t)*4)) |
Functions | |
| void * | tor_malloc_ (size_t size) |
| void * | tor_malloc_zero_ (size_t size) |
| STATIC int | size_mul_check (const size_t x, const size_t y) |
| void * | tor_calloc_ (size_t nmemb, size_t size) |
| void * | tor_realloc_ (void *ptr, size_t size) |
| void * | tor_reallocarray_ (void *ptr, size_t sz1, size_t sz2) |
| char * | tor_strdup_ (const char *s) |
| char * | tor_strndup_ (const char *s, size_t n) |
| void * | tor_memdup_ (const void *mem, size_t len) |
| void * | tor_memdup_nulterm_ (const void *mem, size_t len) |
| void | tor_free_ (void *mem) |
Wrappers for C malloc code, and replacements for items that may be missing.
Definition in file malloc.c.
| #define SQRT_SIZE_MAX_P1 (((size_t)1) << (sizeof(size_t)*4)) |
| STATIC int size_mul_check | ( | const size_t | x, |
| const size_t | y | ||
| ) |
Return non-zero if and only if the product of the arguments is exact, and cannot overflow.
Definition at line 86 of file malloc.c.
Referenced by tor_calloc_(), and tor_reallocarray_().
| void * tor_calloc_ | ( | size_t | nmemb, |
| size_t | size | ||
| ) |
Allocate a chunk of nmemb*size bytes of memory, fill the memory with zero bytes, and return a pointer to the result. Log and terminate the process on error. (Same as calloc(nmemb,size), but never returns NULL.) The second argument (size) should preferably be non-zero and a compile-time constant.
| void tor_free_ | ( | void * | mem | ) |
Helper for places that need to take a function pointer to the right spelling of "free()".
Definition at line 227 of file malloc.c.
Referenced by cert_list_free_(), compute_consensus_package_lines(), control_reply_line_free_(), create_managed_proxy_environment(), dir_split_resource_into_fingerprint_pairs(), dircollator_free_(), dirserv_clear_measured_bw_cache(), dirserv_expire_measured_bw_cache(), dirserv_free_fingerprint_list(), dns_reset_correctness_checks(), free_execve_args(), hs_purge_last_hid_serv_requests(), ns_detached_signatures_free_(), protover_summary_cache_free_all(), replaycache_free_(), service_descriptor_free_(), smartlist_uniq_digests(), smartlist_uniq_digests256(), smartlist_uniq_strings(), sort_version_list(), tor_run_main(), and tor_str_wipe_and_free_().
| void * tor_malloc_ | ( | size_t | size | ) |
Allocate a chunk of size bytes of memory, and return a pointer to result. On error, log and terminate the process. (Same as malloc(size), but never returns NULL.)
Definition at line 32 of file malloc.c.
Referenced by tor_malloc_zero_(), tor_memdup_(), tor_memdup_nulterm_(), tor_run_main(), and tor_strndup_().
| void * tor_malloc_zero_ | ( | size_t | size | ) |
Allocate a chunk of size bytes of memory, fill the memory with zero bytes, and return a pointer to the result. Log and terminate the process on error. (Same as calloc(size,1), but never returns NULL.)
Definition at line 63 of file malloc.c.
Referenced by tor_calloc_().
| void * tor_memdup_ | ( | const void * | mem, |
| size_t | len | ||
| ) |
| void * tor_memdup_nulterm_ | ( | const void * | mem, |
| size_t | len | ||
| ) |
| void * tor_realloc_ | ( | void * | ptr, |
| size_t | size | ||
| ) |
Change the size of the memory block pointed to by ptr to size bytes long; return the new memory block. On error, log and terminate. (Like realloc(ptr,size), but never returns NULL.)
Definition at line 118 of file malloc.c.
Referenced by tor_run_main().
| void * tor_reallocarray_ | ( | void * | ptr, |
| size_t | sz1, | ||
| size_t | sz2 | ||
| ) |
| char * tor_strdup_ | ( | const char * | s | ) |
| char * tor_strndup_ | ( | const char * | s, |
| size_t | n | ||
| ) |