MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / RM_GetSharedAPI

Function RM_GetSharedAPI

src/module.cpp:7480–7489  ·  view source on GitHub ↗

Request an exported API pointer. The return value is just a void pointer * that the caller of this function will be required to cast to the right * function pointer, so this is a private contract between modules. * * If the requested API is not available then NULL is returned. Because * modules can be loaded at different times with different order, this * function calls should be put inside

Source from the content-addressed store, hash-verified

7478 * }
7479 */
7480void *RM_GetSharedAPI(RedisModuleCtx *ctx, const char *apiname) {
7481 dictEntry *de = dictFind(g_pserver->sharedapi, apiname);
7482 if (de == NULL) return NULL;
7483 RedisModuleSharedAPI *sapi = (RedisModuleSharedAPI*)dictGetVal(de);
7484 if (listSearchKey(sapi->module->usedby,ctx->module) == NULL) {
7485 listAddNodeTail(sapi->module->usedby,ctx->module);
7486 listAddNodeTail(ctx->module->usingMods,sapi->module);
7487 }
7488 return sapi->func;
7489}
7490
7491/* Remove all the APIs registered by the specified module. Usually you
7492 * want this when the module is going to be unloaded. This function

Callers

nothing calls this directly

Calls 3

listSearchKeyFunction · 0.85
listAddNodeTailFunction · 0.85
dictFindFunction · 0.70

Tested by

no test coverage detected