[PD] fux_kinect

Claude Heiland-Allen claude at goto10.org
Sat Nov 12 18:13:34 CET 2011

On 12/11/11 16:53, Mathieu Bouchard wrote:
> gl_frame_cond = (pthread_cond_t*) malloc(sizeof(pthread_mutex_t));

A nice idiom for malloc is to use the sizeof of the target of the 
pointer to which you are assigning its result (no explicit cast needed 
when assigning from a void * afaik, at least no warnings/errors here 
with gcc (Debian 4.4.5-8) 4.4.5):

$ gcc -std=c99 -Wall -pedantic -Wextra -Wno-unused-parameter \
   -o malloc malloc.c

#include <stdlib.h>
struct foo { int bar, baz; double quux; };
int main(int argc, char **argv) {
   struct foo *f = malloc(sizeof(*f));
   return 0;


More information about the Pd-list mailing list