Skip to content

Commit 42db8bb

Browse files
author
Walt Karas
authored
Set pcre_malloc/free function pointers in core main() only. (#7608)
1 parent d4fc16f commit 42db8bb

File tree

3 files changed

+0
-62
lines changed

3 files changed

+0
-62
lines changed

plugins/experimental/cookie_remap/cookie_remap.cc

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,6 @@ using namespace std;
4343

4444
const int OVECCOUNT = 30; // We support $1 - $9 only, and this needs to be 3x that
4545

46-
///////////////////////////////////////////////////////////////////////////////
47-
// Helpers for memory management (to make sure pcre uses the TS APIs).
48-
//
49-
inline void *
50-
ink_malloc(size_t s)
51-
{
52-
return TSmalloc(s);
53-
}
54-
55-
inline void
56-
ink_free(void *s)
57-
{
58-
return TSfree(s);
59-
}
60-
6146
class UrlComponents
6247
{
6348
public:
@@ -182,13 +167,6 @@ class UrlComponents
182167
}
183168
};
184169

185-
void
186-
setup_memory_allocation()
187-
{
188-
pcre_malloc = &ink_malloc;
189-
pcre_free = &ink_free;
190-
}
191-
192170
enum operation_type { UNKNOWN = -1, EXISTS = 1, NOTEXISTS, REGEXP, STRING, BUCKET };
193171

194172
enum target_type {
@@ -914,8 +892,6 @@ using OpsQueue = std::vector<const op *>;
914892
TSReturnCode
915893
TSRemapInit(TSRemapInterface *api_info, char *errbuf, int errbuf_size)
916894
{
917-
setup_memory_allocation();
918-
919895
return TS_SUCCESS;
920896
}
921897

plugins/regex_remap/regex_remap.cc

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -638,28 +638,6 @@ struct RemapInstance {
638638
std::string filename;
639639
};
640640

641-
///////////////////////////////////////////////////////////////////////////////
642-
// Helpers for memory management (to make sure pcre uses the TS APIs).
643-
//
644-
inline void *
645-
ts_malloc(size_t s)
646-
{
647-
return TSmalloc(s);
648-
}
649-
650-
inline void
651-
ts_free(void *s)
652-
{
653-
return TSfree(s);
654-
}
655-
656-
void
657-
setup_memory_allocation()
658-
{
659-
pcre_malloc = &ts_malloc;
660-
pcre_free = &ts_free;
661-
}
662-
663641
///////////////////////////////////////////////////////////////////////////////
664642
// Initialize the plugin.
665643
//
@@ -677,7 +655,6 @@ TSRemapInit(TSRemapInterface *api_info, char *errbuf, int errbuf_size)
677655
return TS_ERROR;
678656
}
679657

680-
setup_memory_allocation();
681658
TSDebug(PLUGIN_NAME, "Plugin is successfully initialized");
682659
return TS_SUCCESS;
683660
}

plugins/regex_revalidate/regex_revalidate.c

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,6 @@
4545
#define LOG_ROLL_INTERVAL 86400
4646
#define LOG_ROLL_OFFSET 0
4747

48-
static inline void *
49-
ts_malloc(size_t s)
50-
{
51-
return TSmalloc(s);
52-
}
53-
54-
static inline void
55-
ts_free(void *s)
56-
{
57-
return TSfree(s);
58-
}
59-
6048
typedef struct invalidate_t {
6149
const char *regex_text;
6250
pcre *regex;
@@ -519,9 +507,6 @@ TSPluginInit(int argc, const char *argv[])
519507
TSDebug(LOG_PREFIX, "Plugin registration succeeded");
520508
}
521509

522-
pcre_malloc = &ts_malloc;
523-
pcre_free = &ts_free;
524-
525510
main_cont = TSContCreate(main_handler, NULL);
526511
TSContDataSet(main_cont, (void *)pstate);
527512
TSHttpHookAdd(TS_HTTP_CACHE_LOOKUP_COMPLETE_HOOK, main_cont);

0 commit comments

Comments
 (0)