}
/* Fall through */
case RC_FAIL: /* Fatal error */
+ ASN_STRUCT_FREE(*elm->type, ctx->ptr);
+ ctx->ptr = 0;
RETURN(RC_FAIL);
} /* switch(rval) */
if(!cb || list->count == 0) {
erval.encoded = computed_size;
- _ASN_ENCODED_OK(erval);
+ ASN__ENCODED_OK(erval);
}
/*
erval.encoded = computed_size;
}
- _ASN_ENCODED_OK(erval);
+ ASN__ENCODED_OK(erval);
}
#undef XER_ADVANCE
*/
ch_size = xer_next_token(&ctx->context,
buf_ptr, size, &ch_type);
- switch(ch_size) {
- case -1: RETURN(RC_FAIL);
- case 0: RETURN(RC_WMORE);
- default:
+ if(ch_size == -1) {
+ RETURN(RC_FAIL);
+ } else {
switch(ch_type) {
+ case PXER_WMORE:
+ RETURN(RC_WMORE);
case PXER_COMMENT: /* Got XML comment */
case PXER_TEXT: /* Ignore free-standing text */
XER_ADVANCE(ch_size); /* Skip silently */
asn_app_consume_bytes_f *original_cb = cb;
int i;
- if(!sptr) _ASN_ENCODE_FAILED;
+ if(!sptr) ASN__ENCODE_FAILED;
if(xcan) {
encs = (xer_tmp_enc_t *)MALLOC(list->count * sizeof(encs[0]));
- if(!encs) _ASN_ENCODE_FAILED;
+ if(!encs) ASN__ENCODE_FAILED;
cb = SET_OF_encode_xer_callback;
}
}
if(mname) {
- if(!xcan) _i_ASN_TEXT_INDENT(1, ilevel);
- _ASN_CALLBACK3("<", 1, mname, mlen, ">", 1);
+ if(!xcan) ASN__TEXT_INDENT(1, ilevel);
+ ASN__CALLBACK3("<", 1, mname, mlen, ">", 1);
}
if(!xcan && specs->as_XMLValueList == 1)
- _i_ASN_TEXT_INDENT(1, ilevel + 1);
+ ASN__TEXT_INDENT(1, ilevel + 1);
tmper = elm->type->xer_encoder(elm->type, memb_ptr,
ilevel + (specs->as_XMLValueList != 2),
flags, cb, app_key);
if(tmper.encoded == 0 && specs->as_XMLValueList) {
const char *name = elm->type->xml_tag;
size_t len = strlen(name);
- _ASN_CALLBACK3("<", 1, name, len, "/>", 2);
+ ASN__CALLBACK3("<", 1, name, len, "/>", 2);
}
if(mname) {
- _ASN_CALLBACK3("</", 2, mname, mlen, ">", 1);
+ ASN__CALLBACK3("</", 2, mname, mlen, ">", 1);
er.encoded += 5;
}
er.encoded += (2 * mlen) + tmper.encoded;
}
- if(!xcan) _i_ASN_TEXT_INDENT(1, ilevel - 1);
+ if(!xcan) ASN__TEXT_INDENT(1, ilevel - 1);
if(encs) {
xer_tmp_enc_t *enc = encs;
qsort(encs, encs_count, sizeof(encs[0]), SET_OF_xer_order);
for(; enc < end; enc++) {
- _ASN_CALLBACK(enc->buffer, enc->offset);
+ ASN__CALLBACK(enc->buffer, enc->offset);
FREEMEM(enc->buffer);
enc->buffer = 0;
control_size += enc->offset;
}
FREEMEM(encs);
}
- _ASN_ENCODED_OK(er);
+ ASN__ENCODED_OK(er);
}
int
void
SET_OF_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only) {
if(td && ptr) {
+ asn_SET_OF_specifics_t *specs;
asn_TYPE_member_t *elm = td->elements;
asn_anonymous_set_ *list = _A_SET_FROM_VOID(ptr);
+ asn_struct_ctx_t *ctx; /* Decoder context */
int i;
/*
asn_set_empty(list); /* Remove (list->array) */
+ specs = (asn_SET_OF_specifics_t *)td->specifics;
+ ctx = (asn_struct_ctx_t *)((char *)ptr + specs->ctx_offset);
+ if(ctx->ptr) {
+ ASN_STRUCT_FREE(*elm->type, ctx->ptr);
+ ctx->ptr = 0;
+ }
+
if(!contents_only) {
FREEMEM(ptr);
}
int i;
if(!sptr) {
- _ASN_CTFAIL(app_key, td,
+ ASN__CTFAIL(app_key, td, sptr,
"%s: value not given (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
int repeat = 0;
ssize_t nelems;
- if(_ASN_STACK_OVERFLOW_CHECK(opt_codec_ctx))
- _ASN_DECODE_FAILED;
+ if(ASN__STACK_OVERFLOW_CHECK(opt_codec_ctx))
+ ASN__DECODE_FAILED;
/*
* Create the target structure if it is not present already.
*/
if(!st) {
st = *sptr = CALLOC(1, specs->struct_size);
- if(!st) _ASN_DECODE_FAILED;
+ if(!st) ASN__DECODE_FAILED;
}
list = _A_SET_FROM_VOID(st);
if(ct && ct->flags & APC_EXTENSIBLE) {
int value = per_get_few_bits(pd, 1);
- if(value < 0) _ASN_DECODE_STARVED;
+ if(value < 0) ASN__DECODE_STARVED;
if(value) ct = 0; /* Not restricted! */
}
nelems = per_get_few_bits(pd, ct->effective_bits);
ASN_DEBUG("Preparing to fetch %ld+%ld elements from %s",
(long)nelems, ct->lower_bound, td->name);
- if(nelems < 0) _ASN_DECODE_STARVED;
+ if(nelems < 0) ASN__DECODE_STARVED;
nelems += ct->lower_bound;
} else {
nelems = -1;
nelems = uper_get_length(pd,
ct ? ct->effective_bits : -1, &repeat);
ASN_DEBUG("Got to decode %d elements (eff %d)",
- (int)nelems, ct ? ct->effective_bits : -1);
- if(nelems < 0) _ASN_DECODE_STARVED;
+ (int)nelems, (int)(ct ? ct->effective_bits : -1));
+ if(nelems < 0) ASN__DECODE_STARVED;
}
for(i = 0; i < nelems; i++) {