aboutsummaryrefslogtreecommitdiff
path: root/src/common/mempool.c
Commit message (Collapse)AuthorAge
* Remove tor_malloc_roundup().Nick Mathewson2012-08-13
| | | | | This function never actually did us any good, and it added a little complexity. See the changes file for more info.
* Update copyright dates to 2012; add a few missing copyright statementsNick Mathewson2012-06-04
|
* Remove some duplicate includesAndrea Gelmini2011-11-03
|
* typosRoger Dingledine2011-01-12
|
* Use autoconf's FLEXIBLE_ARRAY_MEMBER for unspecified-length arraysNick Mathewson2011-01-06
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Merge remote branch 'origin/maint-0.2.1' into maint-0.2.2Nick Mathewson2011-01-03
|\ | | | | | | | | | | Conflicts: src/common/test.h src/or/test.c
| * Bump copyright statements to 2011Nick Mathewson2011-01-03
| |
* | Merge remote branch fix_security_bug_021 into fix_security_bug_022Nick Mathewson2010-12-15
|\| | | | | | | | | | | | | Conflicts: src/common/memarea.c src/or/or.h src/or/rendclient.c
| * Have all of our allocation functions and a few others check for underflowNick Mathewson2010-12-13
| | | | | | | | | | | | | | | | | | 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.)
* | Rename log.h to torlog.hNick Mathewson2010-07-09
|/ | | | | | | | | | 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/; }'
* Update Tor Project copyright yearsNick Mathewson2010-02-27
|
* Spelling fixes in comments and stringsNick Mathewson2009-05-27
|
* Update copyright to 2009.Karsten Loesing2009-05-04
|
* Remove svn $Id$s from our source, and remove tor --version --version.Nick Mathewson2009-01-04
| | | | | | | | 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
* Remove some code that is #ifdefed out, and that we no longer seem to use, if ↵Nick Mathewson2008-12-30
| | | | | | we ever did. svn:r17827
* r17659@tombo: nickm | 2008-08-06 12:22:11 -0400Nick Mathewson2008-08-06
| | | | | | | Fix bug 794: recover 3 bytes wasted per memory chunk. Fix from rovv. svn:r16447
* r14374@tombo: nickm | 2008-02-21 16:57:39 -0500Nick Mathewson2008-02-21
| | | | | | | 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
* r18051@catbus: nickm | 2008-02-12 15:20:43 -0500Nick Mathewson2008-02-12
| | | | | | | 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
* r14111@tombo: nickm | 2008-02-10 20:52:19 -0500Nick Mathewson2008-02-11
| | | | | | | "0 bytes in 1 empty chunks" is hardly likely. svn:r13463
* doxygen and other cleanupsRoger Dingledine2008-02-09
| | | | svn:r13440
* r14061@tombo: nickm | 2008-02-08 14:30:42 -0500Nick Mathewson2008-02-08
| | | | | | | 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
* Update some copyright notices: it is now 2008.Nick Mathewson2008-02-07
| | | | svn:r13412
* r17951@catbus: nickm | 2008-02-06 14:34:13 -0500Nick Mathewson2008-02-06
| | | | | | | 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
* r17903@catbus: nickm | 2008-02-05 14:40:03 -0500Nick Mathewson2008-02-05
| | | | | | | 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
* r15691@tombo: nickm | 2007-12-25 18:13:54 -0500Nick Mathewson2007-12-26
| | | | | | | 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
* clean up copyrights, and assign 2007 copyrights to The Tor Project, IncRoger Dingledine2007-12-12
| | | | svn:r12786
* r13476@catbus: nickm | 2007-06-17 14:04:41 -0400Nick Mathewson2007-06-17
| | | | | | | 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
* r13143@catbus: nickm | 2007-06-01 16:43:40 -0400Nick Mathewson2007-06-02
| | | | | | | Try to fix some mipspro compiler warnings. There will still be some left. svn:r10444
* r13111@catbus: nickm | 2007-05-31 15:03:41 -0400Nick Mathewson2007-05-31
| | | | | | | Cleanup whitespace. svn:r10425
* r13050@catbus: nickm | 2007-05-29 13:31:11 -0400Nick Mathewson2007-05-29
| | | | | | | Resolve all but 3 DOCDOCs. svn:r10393
* polish r9933-r9994Roger Dingledine2007-05-25
| | | | svn:r10335
* r12916@catbus: nickm | 2007-05-24 12:43:45 -0400Nick Mathewson2007-05-24
| | | | | | | 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
* r13017@Kushana: nickm | 2007-05-20 13:40:45 -0400Nick Mathewson2007-05-20
| | | | | | | Address points in r10227. svn:r10229
* point out two remote crash bugs, a memory leak, and a few otherRoger Dingledine2007-05-20
| | | | | | | items we should probably look into. svn:r10227
* r12499@catbus: nickm | 2007-04-23 10:42:23 -0400Nick Mathewson2007-04-23
| | | | | | | Keep a freelist of unused 4k buffer chunks, rather than wasting 8k for every inactive connection_t. svn:r10006
* r12458@catbus: nickm | 2007-04-19 15:52:23 -0400Nick Mathewson2007-04-19
| | | | | | | 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
* r12456@catbus: nickm | 2007-04-19 14:47:01 -0400Nick Mathewson2007-04-19
| | | | | | | Make dumpmemusage() dump cell pool usage information. svn:r9991
* r12414@catbus: nickm | 2007-04-16 17:37:17 -0400Nick Mathewson2007-04-16
| | | | | | | More proposal-104 stuff: actually remember extra-info stuff. svn:r9975
* r12353@catbus: nickm | 2007-04-11 15:58:46 -0400Nick Mathewson2007-04-11
| | | | | | | 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
* r12349@catbus: nickm | 2007-04-11 09:18:15 -0400Nick Mathewson2007-04-11
| | | | | | | 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
* r12344@catbus: nickm | 2007-04-10 21:27:25 -0400Nick Mathewson2007-04-11
| | | | | | | Fix documentation and usage of 2nd argument to mp_pool_new. svn:r9942
* r12338@catbus: nickm | 2007-04-10 20:29:05 -0400Nick Mathewson2007-04-11
| | | | | | | Document memory pool implementation, and tweak it even mor. See? Programming is fun. svn:r9940
* r12337@catbus: nickm | 2007-04-10 17:55:26 -0400Nick Mathewson2007-04-11
| | | | | | | Add support for using memory pools to allocate queued cell; pass --disable-cell-pool to configure to disable this. svn:r9939
* r12336@catbus: nickm | 2007-04-10 17:34:25 -0400Nick Mathewson2007-04-11
| | | | | | | Unit tests and debugging for memory pool implementation. svn:r9938
* r12335@catbus: nickm | 2007-04-10 16:53:48 -0400Nick Mathewson2007-04-11
Initial version of memory pool logic. Needs unit tests. Made to be easily separable from Tor. svn:r9937