summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/test/test-malloc.c7
-rw-r--r--src/test/test-malloc.h17
2 files changed, 17 insertions, 7 deletions
diff --git a/src/test/test-malloc.c b/src/test/test-malloc.c
index 55e5a097..3c61d1ee 100644
--- a/src/test/test-malloc.c
+++ b/src/test/test-malloc.c
@@ -177,3 +177,10 @@ void testmalloc_reset() {
void testmalloc_set_max_successful_allocs(int n) {
global_testmalloc_remaining_attempts = n;
}
+
+void testmalloc_get_statistics(struct testmalloc_statistics* statistics) {
+
+ if (statistics) {
+ *statistics = global_testmalloc_statistics;
+ }
+}
diff --git a/src/test/test-malloc.h b/src/test/test-malloc.h
index f92055d0..a68df8aa 100644
--- a/src/test/test-malloc.h
+++ b/src/test/test-malloc.h
@@ -20,6 +20,8 @@ FILE: test-malloc.h
#include <stdint.h>
+#include "libical_ical_export.h"
+
struct testmalloc_statistics {
int malloc_cnt;
int realloc_cnt;
@@ -34,33 +36,34 @@ struct testmalloc_statistics {
int blocks_allocated;
};
-extern struct testmalloc_statistics global_testmalloc_statistics;
-
/** Allocates the specified amount of memory and returns a pointer to the allocated memory.
* Memory allocated using this function must be freed using test_free().
* The number of allocations that can be made using this function can be limited via
* testmalloc_set_max_successful_allocs().
*/
-void *test_malloc(size_t size);
+LIBICAL_ICAL_EXPORT void *test_malloc(size_t size);
/** Resizes the specified buffer.
* Can only be used with memory that has previously been allocated using test_malloc().
*/
-void *test_realloc(void *p, size_t size);
+LIBICAL_ICAL_EXPORT void *test_realloc(void *p, size_t size);
/** Frees a block of memory that has previously been allocated via the test_malloc() function. Specifying memory that
* has not been allocated via test_malloc() causes an assertion.
*/
-void test_free(void *p);
+LIBICAL_ICAL_EXPORT void test_free(void *p);
/** Resets the memory management statistics and sets the number of successful
* allocations limit to infinite.
*/
-void testmalloc_reset();
+LIBICAL_ICAL_EXPORT void testmalloc_reset();
/** Sets the maximum number of malloc or realloc attemts that will succeed. If
* the number is negative, no limit will be applied.
*/
-void testmalloc_set_max_successful_allocs(int n);
+LIBICAL_ICAL_EXPORT void testmalloc_set_max_successful_allocs(int n);
+
+/** Gets current memory allocation statistics. */
+LIBICAL_ICAL_EXPORT void testmalloc_get_statistics(struct testmalloc_statistics *statistics);
#endif /* !TESTMALLOC_H */