Skip to content
This repository has been archived by the owner on Apr 9, 2020. It is now read-only.

Changes the cn_cbor_context macros to use const #50

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Changes the cn_cbor_context macros to use const #50

wants to merge 1 commit into from

Conversation

bergzand
Copy link

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.

@jimsch
Copy link
Contributor

jimsch commented Apr 17, 2018

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.

@bergzand
Copy link
Author

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.

@bergzand
Copy link
Author

bergzand commented May 9, 2018

ping @cabo.

@bergzand
Copy link
Author

@cabo ping

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants