It's been a white since I've written for Microcontrollers, and I'm trying to refactor some code to work on such a device, in C.
I have a line of code:
Pieces = calloc(ARRAYSIZE, sizeof(struct piece));
http://www.cplusplus.com states that calloc:
Allocates a block of memory for an array of num elements, each of them size bytes long
Would the equivalent malloc operation then be:
Pieces = Malloc(ARRAYSIZE*sizeof(struct piece));
Disregarding that the bits haven't been set to 0, isn't that about the same? Or would I have to allocate a block of memory for ARRAYSIZE times?
Hope you can help.
No comments:
Post a Comment