Example #1
0
void DeleteTree(btree* root)
{
	voidBTFuncType delFn;

	delFn = DeleteTree;

    if(root)
    {
        delFn(root->lleaf);
        delFn(root->rleaf);
        printf("Deleting: %s (%d)\n", (char*) root->payload, root->visited);
		free(root);
    }
}
Example #2
0
void
Sdf_ClearPathTableInParallel(void **entryStart, size_t numEntries,
                             void (*delFn)(void *))
{
    // We must release the GIL here if we have it.  If the caller holds the GIL
    // and enters this function and if the elements in the path might try to
    // take the GIL when they're destroyed, then running the destruction in
    // parallel can deadlock since the workers will try to acquire the lock
    // while this thread holds it.
    TF_PY_ALLOW_THREADS_IN_SCOPE();

    WorkParallelForN(
        numEntries,
        [&entryStart, delFn](size_t i, size_t end) {
            for (; i != end; ++i) {
                if (entryStart[i]) {
                    delFn(entryStart[i]);
                    entryStart[i] = nullptr;
                }
            }
        });
}