diff options
author | Nick Mathewson <nickm@torproject.org> | 2008-03-26 16:33:33 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2008-03-26 16:33:33 +0000 |
commit | e4ebe3409e941cf16b2a80a939848deb9e810ca3 (patch) | |
tree | 2b7cf9d451101be36c2bb304737ce9d4bb053462 /src/common/memarea.h | |
parent | 9dfd4132c30db5966e73850c0eac372f544cc672 (diff) | |
download | tor-e4ebe3409e941cf16b2a80a939848deb9e810ca3.tar.gz tor-e4ebe3409e941cf16b2a80a939848deb9e810ca3.zip |
r19049@catbus: nickm | 2008-03-26 12:33:25 -0400
Add new stacklike, free-all-at-once memory allocation strategy. Use it when parsing directory information. This helps parsing speed, and may well help fragmentation some too. hidden-service-related stuff still uses the old tokenizing strategies.
svn:r14194
Diffstat (limited to 'src/common/memarea.h')
-rw-r--r-- | src/common/memarea.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/common/memarea.h b/src/common/memarea.h new file mode 100644 index 0000000000..a13f06bb9a --- /dev/null +++ b/src/common/memarea.h @@ -0,0 +1,22 @@ +/* Copyright (c) 2008, The Tor Project, Inc. */ +/* See LICENSE for licensing information */ +/* $Id$ */ +/* Tor dependencies */ + +#ifndef MEMAREA_H +#define MEMAREA_H + +typedef struct memarea_t memarea_t; + +memarea_t *memarea_new(size_t chunk_size); +void memarea_drop_all(memarea_t *area); +void memarea_clear(memarea_t *area); +int memarea_owns_ptr(const memarea_t *area, const void *ptr); +void *memarea_alloc(memarea_t *area, size_t sz); +void *memarea_alloc_zero(memarea_t *area, size_t sz); +void *memarea_memdup(memarea_t *area, const void *s, size_t n); +char *memarea_strdup(memarea_t *area, const char *s); +char *memarea_strndup(memarea_t *area, const char *s, size_t n); +void memarea_assert_ok(memarea_t *area); + +#endif |