X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?p=ossec-hids.git;a=blobdiff_plain;f=src%2Fos_regex%2Fos_pcre2_free_pattern.c;fp=src%2Fos_regex%2Fos_pcre2_free_pattern.c;h=1cf1c79ccac46537a65ee1b7f60a42ec629ce14f;hp=0000000000000000000000000000000000000000;hb=3f728675941dc69d4e544d3a880a56240a6e394a;hpb=927951d1c1ad45ba9e7325f07d996154a91c911b diff --git a/src/os_regex/os_pcre2_free_pattern.c b/src/os_regex/os_pcre2_free_pattern.c new file mode 100644 index 0000000..1cf1c79 --- /dev/null +++ b/src/os_regex/os_pcre2_free_pattern.c @@ -0,0 +1,46 @@ +/* Copyright (C) 2009 Trend Micro Inc. + * All right reserved. + * + * This program is a free software; you can redistribute it + * and/or modify it under the terms of the GNU General Public + * License (version 2) as published by the FSF - Free Software + * Foundation + */ + +#include +#include +#include + +#include "os_regex.h" + +/* Release all the memory created by the compilation/execution phases */ +void OSPcre2_FreePattern(OSPcre2 *reg) +{ + /* Free the match data */ + if (reg->match_data) { + pcre2_match_data_free(reg->match_data); + reg->match_data = NULL; + } + + /* Free the regex */ + if (reg->regex) { + pcre2_code_free(reg->regex); + reg->regex = NULL; + } + + /* Free the patter, */ + if (reg->pattern) { + free(reg->pattern); + reg->pattern = NULL; + } + + /* Free the sub strings */ + if (reg->sub_strings) { + OSPcre2_FreeSubStrings(reg); + free(reg->sub_strings); + reg->sub_strings = NULL; + } + + return; +} +