Commit 0c6fc519 authored by Nick Mathewson's avatar Nick Mathewson 👁
Browse files

r18793@catbus: nickm | 2008-03-13 14:09:19 -0400

 Add a malloc_good_size() implementation to OpenBSD_malloc_Linux.c.  Also, make configure.in not use support functions for the platform malloc when we are not using the platform mallocs.


svn:r14010
parent 56580ae8
......@@ -22,12 +22,16 @@ Changes in version 0.2.1.1-alpha - 2008-??-??
Fixes bug 625. Bugfix on 0.2.0.x.
- Logging functions now check that the passed severity is sane.
- Use proper log levels in the testsuite call of get_interface_address6().
- When using a nonstandard malloc, do not use the platform values for
HAVE_MALLOC_GOOD_SIZE or HAVE_MALLOC_USABLE_SIZE.
o Minor features:
- Allow separate log levels to be configured for different logging
domains. For example, this allows one to log all notices, warnings, or
errors, plus all memory management messages of level debug or higher,
with: Log [MM] debug-err [*] notice-err file /var/log/tor.
- Add a malloc_good_size implementation to OpenBSD_malloc_linux.c,
to avoid unused RAM in buffer chunks and memory pools.
Changes in version 0.2.0.21-rc - 2008-03-02
......
......@@ -183,7 +183,19 @@ dnl -------------------------------------------------------------------
dnl Check for functions before libevent, since libevent-1.2 apparently
dnl exports strlcpy without defining it in a header.
AC_CHECK_FUNCS(gettimeofday ftime socketpair uname inet_aton strptime getrlimit strlcat strlcpy strtoull ftello getaddrinfo localtime_r gmtime_r memmem strtok_r inet_pton inet_ntop mallinfo malloc_good_size malloc_usable_size)
AC_CHECK_FUNCS(gettimeofday ftime socketpair uname inet_aton strptime getrlimit strlcat strlcpy strtoull ftello getaddrinfo localtime_r gmtime_r memmem strtok_r inet_pton inet_ntop)
using_custom_malloc=no
if test x$enable_openbsd_malloc = xyes ; then
AC_DEFINE(HAVE_MALLOC_GOOD_SIZE, 1, [Defined if we have the malloc_good_size function])
using_custom_malloc=yes
fi
if test x$tcmalloc = xyes ; then
using_custom_malloc=yes
fi
if test $using_custom_malloc = no ; then
AC_CHECK_FUNCS(mallinfo malloc_good_size malloc_usable_size)
fi
if test "$enable_threads" = "yes"; then
AC_CHECK_HEADERS(pthread.h)
......
......@@ -1998,3 +1998,21 @@ void *valloc(size_t size)
posix_memalign(&r, malloc_pagesize, size);
return r;
}
size_t malloc_good_size(size_t size)
{
if (size == 0) {
return 1;
} else if (size <= malloc_maxsize) {
int i, j;
/* round up to the nearest power of 2, with same approach
* as malloc_bytes() uses. */
j = 1;
i = size - 1;
while (i >>= 1)
j++;
return ((size_t)1) << j;
} else {
return pageround(size);
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment