* include/gc.h (GC_get_size_map_at): Declare public function.
* misc.c [!GC_GET_HEAP_USAGE_NOT_NEEDED] (GC_get_size_map_at):
Implement function
* tests/test.c [!GC_GET_HEAP_USAGE_NOT_NEEDED] (check_heap_stats):
Add dummy testing of GC_get_size_map_at.
size_t /* stats_sz */);
#endif
+/* Get the element value (converted to bytes) at a given index of */
+/* size_map table which provides requested-to-actual allocation size */
+/* mapping. Assumes the collector is initialized. Returns -1 if the */
+/* index is out of size_map table bounds. Does not use synchronization. */
+GC_API size_t GC_CALL GC_get_size_map_at(int i);
+
/* Count total memory use in bytes by all allocated blocks. Acquires */
/* the lock. */
GC_API size_t GC_CALL GC_get_memory_use(void);
#ifndef GC_GET_HEAP_USAGE_NOT_NEEDED
+GC_API size_t GC_CALL GC_get_size_map_at(int i)
+{
+ if ((unsigned)i > MAXOBJBYTES)
+ return (size_t)(signed_word)-1;
+ return GRANULES_TO_BYTES(GC_size_map[i]);
+}
+
/* Return the heap usage information. This is a thread-safe (atomic) */
/* alternative for the five above getters. NULL pointer is allowed for */
/* any argument. Returned (filled in) values are of word type. */
(void)GC_get_prof_stats_unsafe(&stats, sizeof(stats));
# endif
}
+ (void)GC_get_size_map_at((size_t)(GC_signed_word)-1);
+ (void)GC_get_size_map_at(1);
# endif
# ifdef THREADS