mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
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
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user