Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F108268471
D27097.id79219.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D27097.id79219.diff
View Options
Index: sys/kern/kern_malloc.c
===================================================================
--- sys/kern/kern_malloc.c
+++ sys/kern/kern_malloc.c
@@ -1030,6 +1030,24 @@
return (mem);
}
+/*
+ * malloc_size: returns the number of bytes allocated for a request of the
+ * specified size
+ */
+size_t
+malloc_size(size_t size)
+{
+ int indx;
+
+ if (size > kmem_zmax) {
+ return (0);
+ }
+ if (size & KMEM_ZMASK)
+ size = (size & ~KMEM_ZMASK) + KMEM_ZBASE;
+ indx = kmemsize[size >> KMEM_ZSHIFT];
+ return (kmemzones[indx].kz_size);
+}
+
/*
* malloc_usable_size: returns the usable size of the allocation.
*/
Index: sys/sys/malloc.h
===================================================================
--- sys/sys/malloc.h
+++ sys/sys/malloc.h
@@ -250,6 +250,7 @@
void malloc_type_freed(struct malloc_type *type, unsigned long size);
void malloc_type_list(malloc_type_list_func_t *, void *);
void malloc_uninit(void *);
+size_t malloc_size(size_t);
size_t malloc_usable_size(const void *);
void *realloc(void *addr, size_t size, struct malloc_type *type, int flags)
__result_use_check __alloc_size(2);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jan 24, 7:16 AM (17 h, 27 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16081018
Default Alt Text
D27097.id79219.diff (1 KB)
Attached To
Mode
D27097: malloc: add a routine to find out usable size without allocating
Attached
Detach File
Event Timeline
Log In to Comment