You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In "Memory management the Chipmunk Way", there is a section which reads:
cpSpaceAlloc() – Allocates but does not initialize a cpSpace struct. All allocation functions look more or less like this: return (cpSpace *)cpcalloc(1, sizeof(cpSpace)); You can write your own allocation functions if you want. It is not a requirement that the memory be zeroed.
..turns out if you don't zero the memory, you can fail on an assert in cSpatialIndexInit() - cSpacialIndex.c line 41:
cpAssertHard(!staticIndex->dynamicIndex, "This static index is already associated with a dynamic index.");
... because the dynamicIndex pointer contains whatever garbage was in memory at alloc time.
The text was updated successfully, but these errors were encountered:
In "Memory management the Chipmunk Way", there is a section which reads:
cpSpaceAlloc() – Allocates but does not initialize a cpSpace struct. All allocation functions look more or less like this: return (cpSpace *)cpcalloc(1, sizeof(cpSpace)); You can write your own allocation functions if you want. It is not a requirement that the memory be zeroed.
..turns out if you don't zero the memory, you can fail on an assert in cSpatialIndexInit() - cSpacialIndex.c line 41:
cpAssertHard(!staticIndex->dynamicIndex, "This static index is already associated with a dynamic index.");
... because the dynamicIndex pointer contains whatever garbage was in memory at alloc time.
The text was updated successfully, but these errors were encountered: