void cpSpaceDestroy(cpSpace *space) { cpSpaceEachBody(space, (cpSpaceBodyIteratorFunc)cpBodyActivateWrap, NULL); cpSpatialIndexFree(space->staticShapes); cpSpatialIndexFree(space->dynamicShapes); cpArrayFree(space->dynamicBodies); cpArrayFree(space->staticBodies); cpArrayFree(space->sleepingComponents); cpArrayFree(space->rousedBodies); cpArrayFree(space->constraints); cpHashSetFree(space->cachedArbiters); cpArrayFree(space->arbiters); cpArrayFree(space->pooledArbiters); if(space->allocatedBuffers){ cpArrayFreeEach(space->allocatedBuffers, cpfree); cpArrayFree(space->allocatedBuffers); } if(space->postStepCallbacks){ cpArrayFreeEach(space->postStepCallbacks, cpfree); cpArrayFree(space->postStepCallbacks); } if(space->collisionHandlers) cpHashSetEach(space->collisionHandlers, FreeWrap, NULL); cpHashSetFree(space->collisionHandlers); }
static void cpBBTreeDestroy(cpBBTree *tree) { cpHashSetFree(tree->leaves); if(tree->allocatedBuffers) cpArrayFreeEach(tree->allocatedBuffers, cpfree); cpArrayFree(tree->allocatedBuffers); }
void cpHashSetFree(cpHashSet *set) { if(set){ cpfree(set->table); cpArrayFreeEach(set->allocatedBuffers, cpfree); cpArrayFree(set->allocatedBuffers); cpfree(set); } }
static void cpSpaceHashDestroy(cpSpaceHash *hash) { if(hash->table) clearTable(hash); cpfree(hash->table); cpHashSetFree(hash->handleSet); cpArrayFreeEach(hash->allocatedBuffers, cpfree); cpArrayFree(hash->allocatedBuffers); cpArrayFree(hash->pooledHandles); }