int KSI_CTX_registerGlobals(KSI_CTX *ctx, int (*initFn)(void), void (*cleanupFn)(void)) { int res = KSI_UNKNOWN_ERROR; size_t *pos = NULL; if (ctx == NULL || initFn == NULL || cleanupFn == NULL) { res = KSI_INVALID_ARGUMENT; goto cleanup; } res = KSI_List_indexOf(ctx->cleanupFnList, (void *)cleanupFn, &pos); if (res != KSI_OK) goto cleanup; /* Only run the init function if the cleanup function is not found. */ if (pos == NULL) { res = initFn(); if (res != KSI_OK) goto cleanup; res = KSI_List_append(ctx->cleanupFnList, (void *)cleanupFn); if (res != KSI_OK) goto cleanup; } res = KSI_OK; cleanup: KSI_free(pos); return res; }
Status CollectionBulkLoaderMock::init(Collection* coll, const std::vector<BSONObj>& secondaryIndexSpecs) { LOG(1) << "CollectionBulkLoaderMock::init called"; stats->initCalled = true; return initFn(coll, secondaryIndexSpecs); };