cn-cbor
cn-cbor copied to clipboard
Changes the cn_cbor_context macros to use const
The cn_cbor_context
struct itself should not be modified by the calls that use the context struct. With this in mind the cn_cbor_context
struct pointer should be passed as const
to the functions using it.
I am not clear what you are trying to do with this. I would need to remove the const by caching in my allocation and free functions. The cn_cbor_context is just a part of the structure I used for doing allocations.
I am not clear what you are trying to do with this.
By changing the macro here I'm changing how the cn_cbor_context
is passed to the functions requiring it. For example from (with the macro expanded):
cn_cbor* cn_cbor_map_create(cn_cbor_context *context, cn_cbor_errback *errp)
to:
cn_cbor* cn_cbor_map_create(const cn_cbor_context *context, cn_cbor_errback *errp)
The idea here is to indicate to the compiler that the passed cn_cbor_context
struct is not modified by the function.
I would need to remove the const by caching in my allocation and free functions. The cn_cbor_context is just a part of the structure I used for doing allocations.
I'm not clear what the problem is you're trying to explain here. Is it possible for you to link a small example where my modification breaks code? This code should not prevent you from modifying the cn_cbor_context
yourself and should not prevent the data where the void pointer of the cn_cbor_context
points to from being modified.
ping @cabo.
@cabo ping