Snaipe / libcsptr

Smart pointers for the (GNU) C programming language
https://snai.pe/c/c-smart-pointers/
MIT License
1.57k stars 143 forks source link

Trying to understand the two available options more clearly #9

Closed kozross closed 8 years ago

kozross commented 9 years ago

In the build descriptionf file, you define two custom options - one for a variadic sentinel, the other to always use malloc. This might sound stupid, but what's the idea behind that? I'm basically trying to understand your code, and this is currently eluding me. Could you please help me understand?

Snaipe commented 9 years ago

I ought to document these two. Will do so asap.

The option to always use malloc is there to allow certain kinds of inlining optimisations done by the compiler; although the code did change a lot since then, so I should probably do some profiling again to see if it is still relevant.

The other option, if turned off, is there to address a request to spare the 4 (or 8 on 64 bit systems) unused bytes acting as a sentinel in the struct-based variadic parameter. Because not having a sentinel yields to nonstandard C99, it is on by default, but people working on embedded systems with very limited memory and compiling with a C compiler supporting GNU extensions can activate this option.

kozross commented 9 years ago

Thanks - that clears it up perfectly!