PUBLIC is a macro that probably expands to nothing - whilst PRIVATE or NONPUBLIC would expand to static (which means that code outside of the source is not able to link to that function).
If we didn't get the memory (node == NULL) then bail out - we CAN NOT continue here if we can't allocate memory.Code:if ( !(node = (LST_BUCKET*)malloc(size + sizeof(LST_BUCKET))) )
It is obviously a decision that depends on the type of application and several other circumstances, whether you for example just return NULL or abort the application (or for that matter, do something different). In small applications, I usually write a "bailout" function that takes a string as parameter, and does "exit(1)" after printing the string. Sometimes it's better to leave the decision whether to quit/continue to some other part of the code, which can for example tell the user in a better way that we couldn't store the data - maybe there is some other app that can be shut down to free some memory, for example?
Yes, it's a void *, so it's returning a "pointer to anything and nothing" in the sense that it can point to anything, but you can't access that pointer until you turn it into something else.
--
Mats