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
| 7478 | * } |
| 7479 | */ |
| 7480 | void *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 |
nothing calls this directly
no test coverage detected