New API function (get_expl_freed_bytes_since_gc)
authorIvan Maidanski <ivmai@mail.ru>
Thu, 11 Jan 2018 21:56:36 +0000 (00:56 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Thu, 11 Jan 2018 21:56:36 +0000 (00:56 +0300)
Note: this function could be used in test_cpp to check that the proper
operator delete is called.

* include/gc.h (GC_get_expl_freed_bytes_since_gc): New function
prototype.
* mallocx.c (GC_get_expl_freed_bytes_since_gc): New function definition
(which returns GC_bytes_freed).

include/gc.h
mallocx.c

index 6b50d29..24a2bd0 100644 (file)
@@ -686,6 +686,10 @@ GC_API size_t GC_CALL GC_get_unmapped_bytes(void);
 /* regarding thread-safety).                                            */
 GC_API size_t GC_CALL GC_get_bytes_since_gc(void);
 
+/* Return the number of explicitly deallocated bytes of memory since    */
+/* the recent collection.  This is an unsynchronized getter.            */
+GC_API size_t GC_CALL GC_get_expl_freed_bytes_since_gc(void);
+
 /* Return the total number of bytes allocated in this process.          */
 /* Never decreases, except due to wrapping.  This is an unsynchronized  */
 /* getter (see GC_get_heap_size comment regarding thread-safety).       */
index 242804a..6440311 100644 (file)
--- a/mallocx.c
+++ b/mallocx.c
@@ -259,6 +259,11 @@ GC_API void GC_CALL GC_incr_bytes_freed(size_t n)
     GC_bytes_freed += n;
 }
 
+GC_API size_t GC_CALL GC_get_expl_freed_bytes_since_gc(void)
+{
+    return (size_t)GC_bytes_freed;
+}
+
 # ifdef PARALLEL_MARK
     STATIC volatile AO_t GC_bytes_allocd_tmp = 0;
                         /* Number of bytes of memory allocated since    */