summaryrefslogtreecommitdiff
path: root/src/common/mempool.c
AgeCommit message (Collapse)Author
2012-11-08Add and use and unlikely-to-be-eliminated memwipe()Nick Mathewson
Apparently some compilers like to eliminate memset() operations on data that's about to go out-of-scope. I've gone with the safest possible replacement, which might be a bit slow. I don't think this is critical path in any way that will affect performance, but if it is, we can work on that in 0.2.4. Fixes bug 7352.
2012-06-04Update copyright dates to 2012; add a few missing copyright statementsNick Mathewson
2011-11-03Remove some duplicate includesAndrea Gelmini
2011-01-12typosRoger Dingledine
2011-01-06Use autoconf's FLEXIBLE_ARRAY_MEMBER for unspecified-length arraysNick Mathewson
C99 allows a syntax for structures whose last element is of unspecified length: struct s { int elt1; ... char last_element[]; }; Recent (last-5-years) autoconf versions provide an AC_C_FLEXIBLE_ARRAY_MEMBER test that defines FLEXIBLE_ARRAY_MEMBER to either no tokens (if you have c99 flexible array support) or to 1 (if you don't). At that point you just use offsetof [STRUCT_OFFSET() for us] to see where last_element begins, and allocate your structures like: struct s { int elt1; ... char last_element[FLEXIBLE_ARRAY_MEMBER]; }; tor_malloc(STRUCT_OFFSET(struct s, last_element) + n_elements*sizeof(char)); The advantages are: 1) It's easier to see which structures and elements are of unspecified length. 2) The compiler and related checking tools can also see which structures and elements are of unspecified length, in case they wants to try weird bounds-checking tricks or something. 3) The compiler can warn us if we do something dumb, like try to stack-allocate a flexible-length structure.
2011-01-03Merge remote branch 'origin/maint-0.2.1' into maint-0.2.2Nick Mathewson
Conflicts: src/common/test.h src/or/test.c
2011-01-03Bump copyright statements to 2011Nick Mathewson
2010-12-15Merge remote branch fix_security_bug_021 into fix_security_bug_022Nick Mathewson
Conflicts: src/common/memarea.c src/or/or.h src/or/rendclient.c
2010-12-13Have all of our allocation functions and a few others check for underflowNick Mathewson
It's all too easy in C to convert an unsigned value to a signed one, which will (on all modern computers) give you a huge signed value. If you have a size_t value of size greater than SSIZE_T_MAX, that is way likelier to be an underflow than it is to be an actual request for more than 2gb of memory in one go. (There's nothing in Tor that should be trying to allocate >2gb chunks.)
2010-07-09Rename log.h to torlog.hNick Mathewson
This should make us conflict less with system files named "log.h". Yes, we shouldn't have been conflicting with those anyway, but some people's compilers act very oddly. The actual change was done with one "git mv", by editing Makefile.am, and running find . -name '*.[ch]' | xargs perl -i -pe 'if (/^#include.*\Wlog.h/) {s/log.h/torlog.h/; }'
2010-02-27Update Tor Project copyright yearsNick Mathewson
2009-05-27Spelling fixes in comments and stringsNick Mathewson
2009-05-04Update copyright to 2009.Karsten Loesing
2009-01-04Remove svn $Id$s from our source, and remove tor --version --version.Nick Mathewson
The subversion $Id$ fields made every commit force a rebuild of whatever file got committed. They were not actually useful for telling the version of Tor files in the wild. svn:r17867
2008-12-30Remove some code that is #ifdefed out, and that we no longer seem to use, if ↵Nick Mathewson
we ever did. svn:r17827
2008-08-06 r17659@tombo: nickm | 2008-08-06 12:22:11 -0400Nick Mathewson
Fix bug 794: recover 3 bytes wasted per memory chunk. Fix from rovv. svn:r16447
2008-02-21 r14374@tombo: nickm | 2008-02-21 16:57:39 -0500Nick Mathewson
Fix all remaining shorten-64-to-32 errors in src/common. Some were genuine problems. Many were compatibility errors with libraries (openssl, zlib) that like predate size_t. Partial backport candidate. svn:r13665
2008-02-12 r18051@catbus: nickm | 2008-02-12 15:20:43 -0500Nick Mathewson
Re-tune mempool parametes based on testing on peacetime: use smaller chuncks, free them a little more aggressively, and try very hard to concentrate allocations on fuller chunks. Also, lots of new documentation. svn:r13484
2008-02-11 r14111@tombo: nickm | 2008-02-10 20:52:19 -0500Nick Mathewson
"0 bytes in 1 empty chunks" is hardly likely. svn:r13463
2008-02-09doxygen and other cleanupsRoger Dingledine
svn:r13440
2008-02-08 r14061@tombo: nickm | 2008-02-08 14:30:42 -0500Nick Mathewson
Add a couple of (currently disabled) strategies for trying to avoid using too much ram in memory pools: prefer putting new cells in almost-full chunks, and be willing to free the last empty chunk if we have not needed it for a while. Also add better output to mp_pool_log_status to track how many mallocs a given memory pool strategy is saving us, so we can tune the mempool parameters. svn:r13428
2008-02-07Update some copyright notices: it is now 2008.Nick Mathewson
svn:r13412
2008-02-06 r17951@catbus: nickm | 2008-02-06 14:34:13 -0500Nick Mathewson
Add more documentation; change the behavior of read_to_buf_tls to be more consistent. Note a longstanding problem with current read/write interfaces. svn:r13407
2008-02-05 r17903@catbus: nickm | 2008-02-05 14:40:03 -0500Nick Mathewson
Remove some dead code; fix some XXX020s; turn some XXX020s into XXXX_IP6s (i.e., "needs to be fixed when we add ipv6 support"). svn:r13382
2007-12-26 r15691@tombo: nickm | 2007-12-25 18:13:54 -0500Nick Mathewson
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
2007-12-12clean up copyrights, and assign 2007 copyrights to The Tor Project, IncRoger Dingledine
svn:r12786
2007-06-17 r13476@catbus: nickm | 2007-06-17 14:04:41 -0400Nick Mathewson
Build with fewer compiler warnings on Sun. (This and previous Sun patches are thanks to the tremendously handy services of unix-center.net.) svn:r10644
2007-06-02 r13143@catbus: nickm | 2007-06-01 16:43:40 -0400Nick Mathewson
Try to fix some mipspro compiler warnings. There will still be some left. svn:r10444
2007-05-31 r13111@catbus: nickm | 2007-05-31 15:03:41 -0400Nick Mathewson
Cleanup whitespace. svn:r10425
2007-05-29 r13050@catbus: nickm | 2007-05-29 13:31:11 -0400Nick Mathewson
Resolve all but 3 DOCDOCs. svn:r10393
2007-05-25polish r9933-r9994Roger Dingledine
svn:r10335
2007-05-24 r12916@catbus: nickm | 2007-05-24 12:43:45 -0400Nick Mathewson
Add math functions to round values to the nearest power of 2. Make mempools more careful about making sure that the size of their chunks is a little less than a power of 2, not a little more. svn:r10304
2007-05-20 r13017@Kushana: nickm | 2007-05-20 13:40:45 -0400Nick Mathewson
Address points in r10227. svn:r10229
2007-05-20point out two remote crash bugs, a memory leak, and a few otherRoger Dingledine
items we should probably look into. svn:r10227
2007-04-23 r12499@catbus: nickm | 2007-04-23 10:42:23 -0400Nick Mathewson
Keep a freelist of unused 4k buffer chunks, rather than wasting 8k for every inactive connection_t. svn:r10006
2007-04-19 r12458@catbus: nickm | 2007-04-19 15:52:23 -0400Nick Mathewson
Fix a bug in displaying memory pool usage. Also dump cell allocation, and track padded_cell_ts as they are allocated and freed, to make sure we are not leaking cells. svn:r9992
2007-04-19 r12456@catbus: nickm | 2007-04-19 14:47:01 -0400Nick Mathewson
Make dumpmemusage() dump cell pool usage information. svn:r9991
2007-04-16 r12414@catbus: nickm | 2007-04-16 17:37:17 -0400Nick Mathewson
More proposal-104 stuff: actually remember extra-info stuff. svn:r9975
2007-04-11 r12353@catbus: nickm | 2007-04-11 15:58:46 -0400Nick Mathewson
Apparently some compilers think that anonymous unions are bad C. Technically, they're right, so let's name the union in mempool.c. svn:r9946
2007-04-11 r12349@catbus: nickm | 2007-04-11 09:18:15 -0400Nick Mathewson
Add code to shrink the cell memory pool by discarding empty chunks that have been empty for the last 60 seconds. Also, instead of having test.c duplicate declarations for exposed functions, put them inside #ifdef foo_PRIVATE blocks in the headers. This prevents bugs where test.c gets out of sync. svn:r9944
2007-04-11 r12344@catbus: nickm | 2007-04-10 21:27:25 -0400Nick Mathewson
Fix documentation and usage of 2nd argument to mp_pool_new. svn:r9942
2007-04-11 r12338@catbus: nickm | 2007-04-10 20:29:05 -0400Nick Mathewson
Document memory pool implementation, and tweak it even mor. See? Programming is fun. svn:r9940
2007-04-11 r12337@catbus: nickm | 2007-04-10 17:55:26 -0400Nick Mathewson
Add support for using memory pools to allocate queued cell; pass --disable-cell-pool to configure to disable this. svn:r9939
2007-04-11 r12336@catbus: nickm | 2007-04-10 17:34:25 -0400Nick Mathewson
Unit tests and debugging for memory pool implementation. svn:r9938
2007-04-11 r12335@catbus: nickm | 2007-04-10 16:53:48 -0400Nick Mathewson
Initial version of memory pool logic. Needs unit tests. Made to be easily separable from Tor. svn:r9937