MCPcopy Create free account
hub / github.com/apache/trafficserver / TSUserArgIndexReserve

Function TSUserArgIndexReserve

src/api/InkAPI.cc:5056–5093  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5054TSReturnCode TSUserArgIndexNameLookup(TSUserArgType type, const char *name, int *arg_idx, const char **description);
5055
5056TSReturnCode
5057TSUserArgIndexReserve(TSUserArgType type, const char *name, const char *description, int *ptr_idx)
5058{
5059 sdk_assert(sdk_sanity_check_null_ptr(ptr_idx) == TS_SUCCESS);
5060 sdk_assert(sdk_sanity_check_null_ptr(name) == TS_SUCCESS);
5061 sdk_assert(0 <= type && type < TS_USER_ARGS_COUNT);
5062
5063 int idx;
5064
5065 /* Since this function is meant to be called during plugin initialization we could end up "leaking" indices during plugins
5066 * reload. Make sure we allocate 1 index per name, also current TSUserArgIndexNameLookup() implementation assumes 1-1
5067 * relationship as well. */
5068 const char *desc;
5069
5070 if (TS_SUCCESS == TSUserArgIndexNameLookup(type, name, &idx, &desc)) {
5071 // Found existing index.
5072
5073 // No need to add get_user_arg_offset(type) here since
5074 // TSUserArgIndexNameLookup already does so.
5075 *ptr_idx = idx;
5076 return TS_SUCCESS;
5077 }
5078
5079 idx = UserArgIdx[type]++;
5080 int limit = MAX_USER_ARGS[type];
5081
5082 if (idx < limit) {
5083 UserArg &arg(UserArgTable[type][idx]);
5084 arg.name = name;
5085 if (description) {
5086 arg.description = description;
5087 }
5088 *ptr_idx = idx + get_user_arg_offset(type);
5089
5090 return TS_SUCCESS;
5091 }
5092 return TS_ERROR;
5093}
5094
5095TSReturnCode
5096TSUserArgIndexLookup(TSUserArgType type, int idx, const char **name, const char **description)

Callers 15

TSRemapDoRemapFunction · 0.85
vconn_arg_handlerFunction · 0.85
TSPluginInitFunction · 0.85
init_helperMethod · 0.85
initMethod · 0.85
TSPluginInitFunction · 0.85
TSRemapInitFunction · 0.85
TSPluginInitFunction · 0.85
acquire_txn_slotMethod · 0.85
TSPluginInitFunction · 0.85

Calls 3

TSUserArgIndexNameLookupFunction · 0.85
get_user_arg_offsetFunction · 0.85

Tested by

no test coverage detected