| From | Sent On | Attachments |
|---|---|---|
| sonia yuditskaya | Oct 25, 2011 6:07 pm | |
| sonia yuditskaya | Oct 25, 2011 6:13 pm | |
| vade | Oct 25, 2011 7:00 pm | |
| Hans-Christoph Steiner | Oct 25, 2011 8:21 pm | |
| sonia yuditskaya | Oct 26, 2011 2:07 pm | |
| Hans-Christoph Steiner | Oct 26, 2011 2:54 pm | |
| sonia yuditskaya | Oct 26, 2011 3:27 pm | |
| Budi Prakosa | Oct 26, 2011 5:25 pm | |
| Hans-Christoph Steiner | Oct 26, 2011 6:00 pm | |
| Hans-Christoph Steiner | Oct 26, 2011 7:25 pm | .patch, .patch |
| Budi Prakosa | Oct 26, 2011 7:49 pm | |
| Hans-Christoph Steiner | Oct 26, 2011 7:54 pm | |
| Budi Prakosa | Oct 26, 2011 10:23 pm | |
| Jordi Sala | Oct 27, 2011 4:39 am | |
| Budi Prakosa | Oct 27, 2011 4:50 am | |
| José Luis Santorcuato Tapia | Nov 11, 2011 4:19 am | |
| Hans-Christoph Steiner | Nov 11, 2011 7:30 am | |
| tim vets | Nov 11, 2011 7:57 am | |
| Hans-Christoph Steiner | Nov 11, 2011 8:02 am | |
| tim vets | Nov 11, 2011 8:06 am | |
| Mathieu Bouchard | Nov 11, 2011 8:38 am | |
| tim vets | Nov 11, 2011 8:55 am | |
| Hans-Christoph Steiner | Nov 11, 2011 9:10 am | |
| Mathieu Bouchard | Nov 11, 2011 10:42 am | |
| tim vets | Nov 11, 2011 10:49 am | |
| tim vets | Nov 11, 2011 10:52 am | |
| tim vets | Nov 11, 2011 11:04 am | |
| tim vets | Nov 11, 2011 11:18 am | |
| tim vets | Nov 11, 2011 11:24 am | |
| Hans-Christoph Steiner | Nov 11, 2011 12:25 pm | |
| Mathieu Bouchard | Nov 11, 2011 12:25 pm | |
| tim vets | Nov 11, 2011 12:54 pm | .Other |
| tim vets | Nov 11, 2011 12:58 pm | |
| Mathieu Bouchard | Nov 12, 2011 8:53 am | |
| Mathieu Bouchard | Nov 12, 2011 8:55 am | |
| Mathieu Bouchard | Nov 12, 2011 9:01 am | |
| Mathieu Bouchard | Nov 12, 2011 9:11 am | |
| Claude Heiland-Allen | Nov 12, 2011 9:13 am | |
| Mathieu Bouchard | Nov 12, 2011 9:15 am | |
| tim vets | Nov 12, 2011 9:19 am | |
| Mathieu Bouchard | Nov 12, 2011 9:30 am | |
| Mathieu Bouchard | Nov 12, 2011 9:33 am | |
| tim vets | Nov 12, 2011 9:55 am | |
| tim vets | Nov 12, 2011 9:58 am | |
| Mathieu Bouchard | Nov 12, 2011 10:04 am | |
| tim vets | Nov 12, 2011 10:08 am | |
| tim vets | Nov 12, 2011 10:10 am | .Other |
| tim vets | Nov 14, 2011 5:44 am | .txt |
| tim vets | Nov 14, 2011 6:41 am | |
| Mathieu Bouchard | Nov 14, 2011 7:53 am | |
| Budi Prakosa | Nov 14, 2011 9:03 am | |
| tim vets | Nov 14, 2011 10:19 am | |
| Matthias Kronlachner | Nov 14, 2011 5:07 pm | |
| tim vets | Nov 15, 2011 6:23 am | |
| tim vets | Nov 15, 2011 7:11 am | |
| Mathieu Bouchard | Nov 15, 2011 7:12 am | |
| Mathieu Bouchard | Nov 15, 2011 7:14 am | |
| Matthias Kronlachner | Nov 15, 2011 11:26 am | |
| Budi Prakosa | Nov 21, 2011 9:24 pm | |
| Mathieu Bouchard | Nov 22, 2011 7:18 am | |
| Budi Prakosa | Nov 22, 2011 4:03 pm |
| Subject: | Re: [PD] fux_kinect | |
|---|---|---|
| From: | Mathieu Bouchard (mat...@artengine.ca) | |
| Date: | Nov 12, 2011 9:30:44 am | |
| List: | at.iem.pd-list | |
Le 2011-11-12 à 17:13:00, Claude Heiland-Allen a écrit :
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): struct foo *f = malloc(sizeof(*f));
1. This does not work in C++ because implicit casts from void* are all assumed to be mistakes ;
2. In any case, this requires that you did type f in the malloc. The problem we have here is because the wrong type name was typed in a sizeof. If a wrong type name can be typed there, so can a wrong variable name.
Therefore, either use «operator new», or if you're stuck with C, use a macro that does the job for you :
#define NEW(T) ((T*)malloc(sizeof(T)))
so that if you do a wrong assignment, you will get an error for it :
struct foo *e = NEW(foo); struct foo *f = NEW(typeof(*f)); struct bar *g = NEW(foo); // wrong struct bar *h = NEW(typeof(*f)); // wrong
error: cannot convert ‘foo*’ to ‘bar*’ in initialization error: cannot convert ‘foo*’ to ‘bar*’ in initialization
But anyway, those mallocs in [fux_kinect] are superfluous because you can reserve that amount of RAM directly in fux_kinect by removing the «*».
That goes for nearly any struct that you need to create at the same time as another struct, and destroy at the same time as that same struct, and never need to change the size of. In order to do that, you need to be able to init and finalise separately from malloc/free. That's why the function is named pthread_cond_init and not pthread_cond_new, for example.
______________________________________________________________________ | Mathieu BOUCHARD ----- téléphone : +1.514.383.3801 ----- Montréal, QC
_______________________________________________
Pd-l...@iem.at mailing list
UNSUBSCRIBE and account-management ->
http://lists.puredata.info/listinfo/pd-list






.patch, .patch