diff options
author | Nick Mathewson <nickm@torproject.org> | 2008-02-19 22:46:19 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2008-02-19 22:46:19 +0000 |
commit | 632c035ad967446f42a546cdf069c04f8b5d1678 (patch) | |
tree | cea4def9af5b172d45fffcc9a36b6466ad830d00 /src/common/container.h | |
parent | c126b79f07a46b506e19733ff312fe6540ae2096 (diff) | |
download | tor-632c035ad967446f42a546cdf069c04f8b5d1678.tar.gz tor-632c035ad967446f42a546cdf069c04f8b5d1678.zip |
r18221@catbus: nickm | 2008-02-19 17:46:16 -0500
New debugging code to figure out what is happending with socket counts.
svn:r13593
Diffstat (limited to 'src/common/container.h')
-rw-r--r-- | src/common/container.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/common/container.h b/src/common/container.h index 6a795d996c..7560ad48c8 100644 --- a/src/common/container.h +++ b/src/common/container.h @@ -336,6 +336,21 @@ bitarray_init_zero(int n_bits) size_t sz = (n_bits+BITARRAY_MASK) / (1u << BITARRAY_SHIFT); return tor_malloc_zero(sz*sizeof(unsigned int)); } +static INLINE bitarray_t * +bitarray_expand(bitarray_t *ba, int n_bits_old, int n_bits_new) +{ + size_t sz_old = (n_bits_old+BITARRAY_MASK) / (1u << BITARRAY_SHIFT); + size_t sz_new = (n_bits_new+BITARRAY_MASK) / (1u << BITARRAY_SHIFT); + char *ptr; + if (sz_new <= sz_old) + return ba; + ptr = tor_realloc(ba, sz_new); + memset(ptr+sz_old, 0, sz_new-sz_old); /* This does nothing to the older + * excess bytes. But they were + * already set to 0 by + * bitarry_init_zero. */ + return (bitarray_t*) ptr; +} /** Free the bit array <b>ba</b>. */ static INLINE void bitarray_free(bitarray_t *ba) |