MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / register_context_destroy

Function register_context_destroy

context.c:41–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39static context_destroy_f *context_destroy_array[CONTEXT_COUNT];
40
41static void register_context_destroy(context_destroy_f f,
42 enum osips_context ctx, enum osips_context_val t)
43{
44 static int count = 0; /* contains all counters */
45 context_destroy_f *tmp;
46 int pos = 0;
47 int i;
48
49 /*
50 * group all functions based on their types:
51 * first the int functions, then the str and pointers the last
52 */
53 switch (t) {
54 case CONTEXT_PTR_TYPE:
55 pos += type_sizes[ctx][CONTEXT_PTR_TYPE];
56 case CONTEXT_STR_TYPE:
57 pos += type_sizes[ctx][CONTEXT_STR_TYPE];
58 case CONTEXT_INT_TYPE:
59 pos += type_sizes[ctx][CONTEXT_INT_TYPE];
60 break;
61 default:
62 LM_ERR("should not get here with ctx %d\n", t);
63 return;
64 }
65 /* TODO: check whether this should be in pkg or shm? */
66 tmp = pkg_realloc(context_destroy_array[ctx], (count + 1) * sizeof(context_destroy_f));
67 if (!tmp) {
68 LM_ERR("cannot add any more destroy functions\n");
69 return;
70 }
71 context_destroy_array[ctx] = tmp;
72
73 /* move everything to the right to make room for pos */
74 for (i = count; i > pos; i--)
75 context_destroy_array[ctx][i] = context_destroy_array[ctx][i - 1];
76 context_destroy_array[ctx][pos] = f;
77 count++;
78}
79
80/* Note: @ctx will *not* be freed! */
81void context_destroy(enum osips_context ctxtype, context_p ctx)

Callers 3

context_register_intFunction · 0.85
context_register_strFunction · 0.85
context_register_ptrFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected