asn1c icon indicating copy to clipboard operation
asn1c copied to clipboard

Is it possible to use ASN1C without dynamic memory allocation?

Open amuroh opened this issue 2 years ago • 4 comments

Hi,

I'm working on a memory constrained platform and I can not use any calloc(), malloc() or free() function calls.

Is it possible to use asn1c generated code with only previously declared static buffers, never using dynamic memory allocation?

Thank you very much,

Álvaro

amuroh avatar Jul 03 '23 15:07 amuroh

I recommend you take a look at ASN1SCC. It generates C and ADA code that exclusively work on the stack. A limit of this means your ASN.1 grammar has to have SIZE contraints everywhere.

kentkost avatar Jul 12 '23 10:07 kentkost

Thank you @kentkost, we know that library, but we discarded using it because we are looking for a library that allows us to use Class types and Extension Marker (...)

If ASN1C could work by passing pointers to static allocated buffers or even providing our own malloc() and free() functions doing that, it would be great. Is that feasible?

amuroh avatar Jul 12 '23 12:07 amuroh

I would say no. Basically the encoders that are generated by ASN1C use dynamic memory allocation. You'd basically have to rewrite each encoder and decoder.

kentkost avatar Jul 12 '23 13:07 kentkost

Understood, thank you so much.

amuroh avatar Jul 12 '23 13:07 amuroh