3 ms·
In image_new, doesn't he want to allocate enough memory for an Image rather than for whatever the sizeof an image* is?
by jrockway 15y ago
In image_new, doesn't he want to allocate enough memory for an Image rather than for whatever the sizeof an image* is?
- kragen 15y agoNo, image is an Image, so image is an Image, so sizeof image is the amount of memory you need to allocate for an Image. Saying sizeof image rather than sizeof Image allows you to change the type of image in one fewer place, should you want to do that.
- kragen 15y agoFucking piece of shit Arc. I'm very sorry that this comment I wrote above is completely fucking wrong because of the deletion of asterisks.
- deleted 15y ago[deleted]
- jrockway 15y agoI knew what you meant. I tend to use ∗ when I can't get * to work.
- biot 15y agoAbove comment indented with two spaces to preserve asterisks: No, image is an Image*, so *image is an Image, so sizeof(*image) is the amount of memory you need to allocate for an Image. Saying sizeof(*image) rather than sizeof(Image) allows you to change the type of image in one fewer place, should you want to do that.
- kragen 15y agoThank you!
- davvid 15y agoIt is de-referencing the image pointer, *image, and taking its size.