sizeof (c) vs sizeof (*c)
"Neal H. Walfield" <[email protected]> Sun, 13 Aug 2006 09:06:30 +0200
| Newsgroups | gmane.comp.handhelds.gpe |
|---|---|
| Message-ID | <87hd0hazd5.wl%[email protected]> |
At Sat, 12 Aug 2006 02:17:55 +0200, Florian Boor wrote: > > - Could it be that in libgpepimc in file db.c at line 48 it should be > > > > struct gpe_pim_category *c = g_malloc0 (sizeof (struct gpe_pim_category)); > > > > instead of > > > > struct gpe_pim_category *c = g_malloc0 (sizeof (c)); > > That looks a little bit strange, could someone verify if this is correct? In > fact i would prefer the first solution even if the second is correct. Well *if* the second is correct, I don't see why you'd prefer the first as it is saying something very different. sizeof (c) is here the size of a pointer so even if it happens that sizeof (struct gpe_pim_category) is the size of a pointer, the code is wrong. The programmer likely intended to write sizeof (*c). Neal