Introduce new function malloc_roundup(), suggested by Bill Sommerfeld
on tech-kern.
This commit is contained in:
parent
037eb62a0f
commit
996ee10484
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: kern_malloc.c,v 1.69 2001/12/04 23:56:36 enami Exp $ */
|
||||
/* $NetBSD: kern_malloc.c,v 1.70 2001/12/05 01:29:04 enami Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
|
||||
|
@ -37,7 +37,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_malloc.c,v 1.69 2001/12/04 23:56:36 enami Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_malloc.c,v 1.70 2001/12/05 01:29:04 enami Exp $");
|
||||
|
||||
#include "opt_lockdebug.h"
|
||||
|
||||
|
@ -625,6 +625,19 @@ realloc(void *curaddr, unsigned long newsize, int type, int flags)
|
|||
return (newaddr);
|
||||
}
|
||||
|
||||
/*
|
||||
* Roundup size to the actual allocation size.
|
||||
*/
|
||||
unsigned long
|
||||
malloc_roundup(unsigned long size)
|
||||
{
|
||||
|
||||
if (size > MAXALLOCSAVE)
|
||||
return (roundup(size, PAGE_SIZE));
|
||||
else
|
||||
return (1 << BUCKETINDX(size));
|
||||
}
|
||||
|
||||
/*
|
||||
* Compute the number of pages that kmem_map will map, that is,
|
||||
* the size of the kernel malloc arena.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: malloc.h,v 1.71 2001/12/05 00:00:10 enami Exp $ */
|
||||
/* $NetBSD: malloc.h,v 1.72 2001/12/05 01:29:05 enami Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1987, 1993
|
||||
|
@ -457,5 +457,7 @@ void debug_malloc_printit(void (*)(const char *, ...), vaddr_t);
|
|||
|
||||
void *realloc(void *curaddr, unsigned long newsize, int type,
|
||||
int flags);
|
||||
unsigned long
|
||||
malloc_roundup(unsigned long);
|
||||
#endif /* _KERNEL */
|
||||
#endif /* !_SYS_MALLOC_H_ */
|
||||
|
|
Loading…
Reference in New Issue