diff options
author | Harald Welte <laforge@gnumonks.org> | 2010-07-18 23:15:24 +0200 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2010-07-20 00:05:07 +0200 |
commit | fa034009a11b0ea5f91074e6137e8711240217a6 (patch) | |
tree | 43d6fbed6f5301946749e6140600f09bddc6f23a | |
parent | ec0e217b0647eb798576a7d3366b39c159c00624 (diff) |
Convert libasn1c to use talloc from libosmocore
-rw-r--r-- | asn1c-talloc.patch | 30 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | include/asn1c/asn_internal.h | 12 | ||||
-rw-r--r-- | src/Makefile.am | 3 | ||||
-rw-r--r-- | src/asn_codecs_prim.c | 2 |
5 files changed, 44 insertions, 5 deletions
diff --git a/asn1c-talloc.patch b/asn1c-talloc.patch new file mode 100644 index 0000000..f0a32b0 --- /dev/null +++ b/asn1c-talloc.patch @@ -0,0 +1,30 @@ +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_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. diff --git a/configure.ac b/configure.ac index 00d9035..6fc752a 100644 --- a/configure.ac +++ b/configure.ac @@ -15,6 +15,8 @@ AC_PROG_LIBTOOL AC_CONFIG_MACRO_DIR([m4]) +PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 0.1.13) + # The following test is taken from WebKit's webkit.m4 saved_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -fvisibility=hidden " diff --git a/include/asn1c/asn_internal.h b/include/asn1c/asn_internal.h index 249d7ef..47f9930 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 922 /* 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_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. diff --git a/src/Makefile.am b/src/Makefile.am index dcad645..d4e105e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -4,9 +4,10 @@ LIBVERSION=0:0:0 INCLUDES = $(all_includes) -I$(top_srcdir)/include/asn1c -AM_CFLAGS = -fPIC -Wall +AM_CFLAGS = -fPIC -Wall $(LIBOSMOCORE_CFLAGS) lib_LTLIBRARIES = libasn1c.la +libasn1c_la_LDFLAGS = $(LIBOSMOCORE_LIBS) libasn1c_la_SOURCES = ANY.c constraints.c GeneralizedTime.c NumericString.c T61String.c asn_codecs_prim.c constr_CHOICE.c GeneralString.c ObjectDescriptor.c TeletexString.c asn_SEQUENCE_OF.c constr_SEQUENCE.c GraphicString.c OBJECT_IDENTIFIER.c UniversalString.c asn_SET_OF.c constr_SEQUENCE_OF.c IA5String.c OCTET_STRING.c UTCTime.c ber_decoder.c constr_SET.c INTEGER.c per_decoder.c UTF8String.c ber_tlv_length.c constr_SET_OF.c ISO646String.c per_encoder.c VideotexString.c ber_tlv_tag.c constr_TYPE.c NativeEnumerated.c per_support.c VisibleString.c BIT_STRING.c NativeInteger.c PrintableString.c xer_decoder.c BMPString.c der_encoder.c NativeReal.c REAL.c xer_encoder.c BOOLEAN.c ENUMERATED.c NULL.c RELATIVE-OID.c xer_support.c per_opentype.c diff --git a/src/asn_codecs_prim.c b/src/asn_codecs_prim.c index 4e5c639..a9bc10d 100644 --- a/src/asn_codecs_prim.c +++ b/src/asn_codecs_prim.c @@ -6,6 +6,8 @@ #include <asn_codecs_prim.h> #include <errno.h> +void *talloc_asn1_ctx; + /* * Decode an always-primitive type. */ |