[FIX] Resolve questions about function pointer cast to (void *)
+ some standardization
#40
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The necessity for the
(void *)
typecasting was caused by the function declarations of the functions expecting function pointers.If a function expects a function ptr which argument is
(void *)
, the argument of the function that gets passed as a function ptr also needs to be of type(void *)
.Otherwise, typecasting is needed - and weirdly this is done in front of the function ptr.
What this means going forward:
Whenever we have to typecast a function pointer to
(void *)
, it means we should be careful what types we pass to this function pointer because it can only handle a certain type.Other improvements:
Make use of libft functions for freeing and remove unnecessary
NULL
checks.Standardize
cur
variable name (replacing last remaining instance ofcurr
).Protect against segfault in
get_state_from_stack()
function.Remove
NULL
checks beforeft_free_and_null()
because it checks by itself.Instead of
(void *)
arguments, specify for all free functions what types they can free.Standardize NO space after typcasting.