cn-uofbasel / ccn-lite

CCN-lite, a lightweight implementation of the CCNx protocol and its variations
ISC License
74 stars 63 forks source link

struct ccnl_buf_s has only one byte of data #7

Closed mehlis closed 11 years ago

mehlis commented 11 years ago

https://github.com/cn-uofbasel/ccn-lite/blob/master/ccnl-core.h#L112

I think this should be like MAX_DATA_LEN not 1

the data field is used for storing the content, right now it uses the memory after this struct. this struct is created via calloc, so we are in the heap.

tschudin commented 11 years ago

On Mon, 2 Sep 2013, Christian Mehlis wrote:

https://github.com/cn-uofbasel/ccn-lite/blob/master/ccnl-core.h#L112

I think this should be like MAX_DATA_LEN not 1

the data field is used for storing the content, right now it uses the memory after this struct. this struct is created via calloc, so we are in the heap.

The ccnl_buf_s structure is but a header.

The len of 1 is correct (with 0, which I would have preferred, the compiler is not happy).

The real length of a buffer is allocated in ccnl-core.c#L35 In fact, we allocate 1 byte too much.

best, christian

mehlis commented 11 years ago

I see, you are right. I don't see a better way to implement this without this dummy array. Perhaps a comment in source code would be nice for the next time someone is confused.