Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Storing fixed sized strings in parsed C struct #368

Open
mkschreder opened this issue Oct 5, 2023 · 2 comments
Open

Storing fixed sized strings in parsed C struct #368

mkschreder opened this issue Oct 5, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@mkschreder
Copy link

Is it possible to instruct zcbor to store string data as value in generated structure instead of just a pointer?

It would be convenient to avoid dependency on the CBOR binary blob sometimes and to have everything within the C data structure instead.

@mkschreder mkschreder changed the title Storing fixed sized strings in parsed data Storing fixed sized strings in parsed C struct Oct 5, 2023
@oyvindronningstad
Copy link
Collaborator

zcbor is built to not use malloc, so acheiving this would require some choices regarding memory management. Maybe the answer is to have a callback for allocating memory. In case I find time for this, what sort of context are you working in? Constrained, or would malloc be fine?

@mkschreder
Copy link
Author

be

I think it would be nice if it was possible to set maximum text size in CDDL using an attribute like .size and then reserving this space in the C struct. Not ideal but would be good to have this possibility where one does not want to store the blob side by side with parsed data.

Also, for the case using malloc it would be good to allow custom allocator so that it is possible to allocate them in a slab or a custom heap.

@oyvindronningstad oyvindronningstad added the enhancement New feature or request label Aug 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants