Skip to content

Pointer Parameters #21427

Closed Answered by kripken
cemalgnlts asked this question in Q&A
Feb 26, 2024 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

If Color is a struct then clang will use an allocated area in memory, so you do need to malloc as you do here (and free, as nothing else knows you allocated it). Another option is to allocate on the stack (stackAlloc) if you know it is small. However, most people change their API to avoid passing structs, and leave only simple types on the boundary, like this:

void ClearBackground(unsigned char r, unsigned char g, unsigned char b, unsigned char a);

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@cemalgnlts
Comment options

Answer selected by cemalgnlts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants