OpenKinect/libfreenect — Issue #261: void* typecasts in memory allocations and assignments.
Author: datenwolf
Created: 2011-11-22 13:34:19+00:00
State: open

Throughout the libfreenect code one can find lines like

*ctx = (freenect_context*)malloc(sizeof(freenect_context));

This is how one would write it in old C++ (before introduction of the `…_cast<…>` operators). However libfreenect code is supposed to be C, and in C one should directly assign `void*` to L values without a typecast of the R value. In fact, such casts should be avoided.

For further explanation see

http://c-faq.com/malloc/mallocnocast.html
and
http://c-faq.com/malloc/cast.html