diff options
author | Nick Mathewson <nickm@torproject.org> | 2007-12-26 00:12:01 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2007-12-26 00:12:01 +0000 |
commit | 0c8142e981497359d86d6c8825455d315d99d3fb (patch) | |
tree | aadf197afe2c9ca486a723a71950b43af04077f6 /src/common/util.h | |
parent | 0421e53c66547275bdf4bf2e6aafe112402a330a (diff) | |
download | tor-0c8142e981497359d86d6c8825455d315d99d3fb.tar.gz tor-0c8142e981497359d86d6c8825455d315d99d3fb.zip |
r15691@tombo: nickm | 2007-12-25 18:13:54 -0500
New, slightly esoteric function, tor_malloc_roundup(). While tor_malloc(x) allocates x bytes, tor_malloc_roundup(&x) allocates the same size of chunk it would use to store x bytes, and sets x to the usable size of that chunk.
svn:r12981
Diffstat (limited to 'src/common/util.h')
-rw-r--r-- | src/common/util.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/common/util.h b/src/common/util.h index c0343cf2fd..d69c919964 100644 --- a/src/common/util.h +++ b/src/common/util.h @@ -75,6 +75,7 @@ /* Memory management */ void *_tor_malloc(size_t size DMALLOC_PARAMS) ATTR_MALLOC; void *_tor_malloc_zero(size_t size DMALLOC_PARAMS) ATTR_MALLOC; +void *_tor_malloc_roundup(size_t *size DMALLOC_PARAMS) ATTR_MALLOC; void *_tor_realloc(void *ptr, size_t size DMALLOC_PARAMS); char *_tor_strdup(const char *s DMALLOC_PARAMS) ATTR_MALLOC ATTR_NONNULL((1)); char *_tor_strndup(const char *s, size_t n DMALLOC_PARAMS) @@ -102,6 +103,7 @@ extern int dmalloc_free(const char *file, const int line, void *pnt, #define tor_malloc(size) _tor_malloc(size DMALLOC_ARGS) #define tor_malloc_zero(size) _tor_malloc_zero(size DMALLOC_ARGS) +#define tor_malloc_roundup(szp) _tor_malloc_roundup(szp DMALLOC_ARGS) #define tor_realloc(ptr, size) _tor_realloc(ptr, size DMALLOC_ARGS) #define tor_strdup(s) _tor_strdup(s DMALLOC_ARGS) #define tor_strndup(s, n) _tor_strndup(s, n DMALLOC_ARGS) |