blob: 909772f038cb71498bdf901f6a5e6924d14a7b58 [file] [log] [blame]
diff --git a/include/asn1c/asn_internal.h b/include/asn1c/asn_internal.h
index 67f055a..45b1adb 100644
--- a/include/asn1c/asn_internal.h
+++ b/include/asn1c/asn_internal.h
@@ -15,6 +15,8 @@
#include <assert.h> /* for assert() macro */
#endif
+#include <osmocore/talloc.h>
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -23,10 +25,12 @@ extern "C" {
#define ASN1C_ENVIRONMENT_VERSION 920 /* Compile-time version */
int get_asn1c_environment_version(void); /* Run-time version */
-#define CALLOC(nmemb, size) calloc(nmemb, size)
-#define MALLOC(size) malloc(size)
-#define REALLOC(oldptr, size) realloc(oldptr, size)
-#define FREEMEM(ptr) free(ptr)
+extern void *talloc_asn1_ctx;
+
+#define CALLOC(nmemb, size) talloc_zero_size(talloc_asn1_ctx, (nmemb) * (size))
+#define MALLOC(size) talloc_size(talloc_asn1_ctx, size)
+#define REALLOC(oldptr, size) talloc_realloc_size(talloc_asn1_ctx, oldptr, size)
+#define FREEMEM(ptr) talloc_free(ptr)
/*
* A macro for debugging the ASN.1 internals.