Site icon Bytefreaks.net

asn1c: How do I know how big a buffer to allocate before using ‘uper_encode_to_new_buffer’?

Advertisements

The following post is for the https://lionet.info/asn1c/ (repository: https://github.com/vlm/asn1c/)

There is no need to compute the space needed.

If you pass the address to a pointer that is NULL pointer as the last parameter of uper_encode_to_new_buffer(asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void *sptr, void **buffer_r) , then it will allocate by itself the required space.


void *buffer = NULL;
asn_per_constraints_s *constraints = NULL;
ssize_t ec = uper_encode_to_new_buffer(&asn_DEF_Image, constraints, image, &buffer);

This post is also available in: Greek

Exit mobile version