[haiku-commits] haiku: hrev53805 - src/system/libroot/posix/malloc_debug

  • From: waddlesplash <waddlesplash@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 2 Feb 2020 18:38:41 -0500 (EST)

hrev53805 adds 1 changeset to branch 'master'
old head: fdc13d7d973cfd64241cd072e0c09bea5034e116
new head: c529e2a3546708d052de98dfc07480603bd68f02
overview: 
https://git.haiku-os.org/haiku/log/?qt=range&q=c529e2a35467+%5Efdc13d7d973c

----------------------------------------------------------------------------

c529e2a35467: debug heap: implement malloc_usable_size
  
  Change-Id: I49d7918df00cca4b889f6a3cf52c3f903ee5fa2a
  Reviewed-on: https://review.haiku-os.org/c/haiku/+/2179
  Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>

                                              [ X512 <danger_mail@xxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev53805
Commit:      c529e2a3546708d052de98dfc07480603bd68f02
URL:         https://git.haiku-os.org/haiku/commit/?id=c529e2a35467
Author:      X512 <danger_mail@xxxxxxx>
Date:        Sun Feb  2 08:53:33 2020 UTC
Committer:   waddlesplash <waddlesplash@xxxxxxxxx>
Commit-Date: Sun Feb  2 23:38:37 2020 UTC

----------------------------------------------------------------------------

1 file changed, 18 insertions(+)
.../posix/malloc_debug/malloc_debug_api.cpp        | 18 ++++++++++++++++++

----------------------------------------------------------------------------

diff --git a/src/system/libroot/posix/malloc_debug/malloc_debug_api.cpp 
b/src/system/libroot/posix/malloc_debug/malloc_debug_api.cpp
index 4a0f87022a..9f03044188 100644
--- a/src/system/libroot/posix/malloc_debug/malloc_debug_api.cpp
+++ b/src/system/libroot/posix/malloc_debug/malloc_debug_api.cpp
@@ -302,3 +302,21 @@ posix_memalign(void **pointer, size_t alignment, size_t 
size)
 
        return 0;
 }
+
+
+extern "C" size_t
+malloc_usable_size(void *ptr)
+{
+       size_t size;
+       thread_id thread;
+
+       if (ptr == NULL)
+               return 0;
+
+       status_t res = sCurrentHeap->get_allocation_info(ptr, &size, &thread);
+
+       if (res != B_OK)
+               return 0;
+
+       return size;
+}


Other related posts:

  • » [haiku-commits] haiku: hrev53805 - src/system/libroot/posix/malloc_debug - waddlesplash