It is calling the standard library function malloc()
, to allocate sizeof (struct forcePin)
bytes of dynamic ("heap") memory.
It is then pointlessly casting the returned pointer, and storing it in the variable _forcePin[i]
.
It's not the optimal way to write this code, in my opinion it should be:
_forcePin[i] = malloc(sizeof *_forcePin[i]);
Note that if the allocation is broken out of a loop (as the i
implies), then that code looks like it's allocating 512 * 500,000 bytes, or around 244 MB of memory. Since it's done in half a million allocation calls, there will be considerable overhead, too.
If all the memory really is needed, it would be better to try for a single malloc()
call and then split the allocated buffer into the 500,000 parts. Doing it that way would very likely be faster since malloc()
can be expensive and half a million calls is a lot, but it would certainly save memory since there would be a one overhead cost rather than 500,000.