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:
Nick Mathewson
2008-03-13 18:11:33 +00:00
parent 56580ae84e
commit 0c6fc51909
3 changed files with 35 additions and 1 deletions
+18
View File
@@ -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);
}
}