mirror of https://gerrit.osmocom.org/asn1c
macro for free_struct()
This commit is contained in:
parent
8253ea93aa
commit
adcb586c0c
|
@ -133,7 +133,7 @@ ANY_to_type(ANY_t *st, asn_TYPE_descriptor_t *td, void **struct_ptr) {
|
|||
return 0;
|
||||
} else {
|
||||
/* Remove possibly partially decoded data. */
|
||||
td->free_struct(td, newst, 0);
|
||||
ASN_STRUCT_FREE(*td, newst);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -218,8 +218,7 @@ GeneralizedTime_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
|||
|
||||
rv = OCTET_STRING_encode_xer_utf8(td, sptr, ilevel, flags,
|
||||
cb, app_key);
|
||||
asn_DEF_GeneralizedTime.free_struct(&asn_DEF_GeneralizedTime,
|
||||
gt, 0);
|
||||
ASN_STRUCT_FREE(asn_DEF_GeneralizedTime, gt);
|
||||
return rv;
|
||||
} else {
|
||||
return OCTET_STRING_encode_xer_utf8(td, sptr, ilevel, flags,
|
||||
|
|
|
@ -194,7 +194,7 @@ NativeInteger_decode_xer(asn_codec_ctx_t *opt_codec_ctx,
|
|||
*/
|
||||
rval.consumed = 0;
|
||||
}
|
||||
asn_DEF_INTEGER.free_struct(&asn_DEF_INTEGER, &st, 1);
|
||||
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_INTEGER, &st);
|
||||
return rval;
|
||||
}
|
||||
|
||||
|
@ -248,7 +248,7 @@ NativeInteger_decode_uper(asn_codec_ctx_t *opt_codec_ctx,
|
|||
ASN_DEBUG("NativeInteger %s got value %ld",
|
||||
td->name, *native);
|
||||
}
|
||||
asn_DEF_INTEGER.free_struct(&asn_DEF_INTEGER, &tmpint, 1);
|
||||
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_INTEGER, &tmpint);
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
|
|
@ -152,7 +152,7 @@ NativeReal_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
|
|||
}
|
||||
|
||||
/* Free possibly allocated members of the temporary structure */
|
||||
asn_DEF_REAL.free_struct(&asn_DEF_REAL, &tmp, 1);
|
||||
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_REAL, &tmp);
|
||||
|
||||
return erval;
|
||||
}
|
||||
|
@ -190,7 +190,7 @@ NativeReal_decode_xer(asn_codec_ctx_t *opt_codec_ctx,
|
|||
} else {
|
||||
rval.consumed = 0;
|
||||
}
|
||||
asn_DEF_REAL.free_struct(&asn_DEF_REAL, st, 0);
|
||||
ASN_STRUCT_FREE(asn_DEF_REAL, st);
|
||||
return rval;
|
||||
}
|
||||
|
||||
|
|
|
@ -244,7 +244,7 @@ main(int ac, char **av) {
|
|||
break;
|
||||
}
|
||||
|
||||
pduType->free_struct(pduType, structure, 0);
|
||||
ASN_STRUCT_FREE(*pduType, structure);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -425,7 +425,7 @@ static void *data_decode_from_file(asn_TYPE_descriptor_t *pduType, const char *f
|
|||
fclose(fp);
|
||||
|
||||
/* Clean up partially decoded structure */
|
||||
pduType->free_struct(pduType, structure, 0);
|
||||
ASN_STRUCT_FREE(*pduType, structure);
|
||||
|
||||
fprintf(stderr, "%s: "
|
||||
"Decode failed past byte %ld: %s\n",
|
||||
|
|
|
@ -959,10 +959,10 @@ CHOICE_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only) {
|
|||
if(elm->flags & ATF_POINTER) {
|
||||
memb_ptr = *(void **)((char *)ptr + elm->memb_offset);
|
||||
if(memb_ptr)
|
||||
elm->type->free_struct(elm->type, memb_ptr, 0);
|
||||
ASN_STRUCT_FREE(*elm->type, memb_ptr);
|
||||
} else {
|
||||
memb_ptr = (void *)((char *)ptr + elm->memb_offset);
|
||||
elm->type->free_struct(elm->type, memb_ptr, 1);
|
||||
ASN_STRUCT_FREE_CONTENTS_ONLY(*elm->type, memb_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -958,10 +958,10 @@ SEQUENCE_free(asn_TYPE_descriptor_t *td, void *sptr, int contents_only) {
|
|||
if(elm->flags & ATF_POINTER) {
|
||||
memb_ptr = *(void **)((char *)sptr + elm->memb_offset);
|
||||
if(memb_ptr)
|
||||
elm->type->free_struct(elm->type, memb_ptr, 0);
|
||||
ASN_STRUCT_FREE(*elm->type, memb_ptr);
|
||||
} else {
|
||||
memb_ptr = (void *)((char *)sptr + elm->memb_offset);
|
||||
elm->type->free_struct(elm->type, memb_ptr, 1);
|
||||
ASN_STRUCT_FREE_CONTENTS_ONLY(*elm->type, memb_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -924,10 +924,10 @@ SET_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only) {
|
|||
if(elm->flags & ATF_POINTER) {
|
||||
memb_ptr = *(void **)((char *)ptr + elm->memb_offset);
|
||||
if(memb_ptr)
|
||||
elm->type->free_struct(elm->type, memb_ptr, 0);
|
||||
ASN_STRUCT_FREE(*elm->type, memb_ptr);
|
||||
} else {
|
||||
memb_ptr = (void *)((char *)ptr + elm->memb_offset);
|
||||
elm->type->free_struct(elm->type, memb_ptr, 1);
|
||||
ASN_STRUCT_FREE_CONTENTS_ONLY(*elm->type, memb_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -798,7 +798,7 @@ SET_OF_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only) {
|
|||
for(i = 0; i < list->count; i++) {
|
||||
void *memb_ptr = list->array[i];
|
||||
if(memb_ptr)
|
||||
elm->type->free_struct(elm->type, memb_ptr, 0);
|
||||
ASN_STRUCT_FREE(*elm->type, memb_ptr);
|
||||
}
|
||||
list->count = 0; /* No meaningful elements left */
|
||||
|
||||
|
@ -925,7 +925,7 @@ SET_OF_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
|||
ASN_DEBUG("Failed decoding %s of %s (SET OF)",
|
||||
elm->type->name, td->name);
|
||||
}
|
||||
if(ptr) elm->type->free_struct(elm->type, ptr, 0);
|
||||
if(ptr) ASN_STRUCT_FREE(*elm->type, ptr);
|
||||
_ASN_DECODE_FAILED;
|
||||
}
|
||||
|
||||
|
|
|
@ -52,6 +52,9 @@ typedef struct asn_struct_ctx_s {
|
|||
typedef void (asn_struct_free_f)(
|
||||
struct asn_TYPE_descriptor_s *type_descriptor,
|
||||
void *struct_ptr, int free_contents_only);
|
||||
#define ASN_STRUCT_FREE(asn_DEF, ptr) (asn_DEF).free_struct(&(asn_DEF),ptr,0)
|
||||
#define ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF, ptr) \
|
||||
(asn_DEF).free_struct(&(asn_DEF),ptr,1)
|
||||
|
||||
/*
|
||||
* Print the structure according to its specification.
|
||||
|
|
Loading…
Reference in New Issue