new upstream release (3.3.0); modify package compatibility for Stretch
[ossec-hids.git] / src / os_regex / os_match_free_pattern.c
old mode 100755 (executable)
new mode 100644 (file)
index 095f8c9..2a2cead
@@ -1,15 +1,12 @@
-/*   $OSSEC, os_match_free_pattern.c, v0.1, 2006/04/18, Daniel B. Cid$   */
-
 /* 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 3) as published by the FSF - Free Software
+ * License (version 2) as published by the FSF - Free Software
  * Foundation
  */
 
-
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
 #include "os_regex_internal.h"
 
 
-/** int OSMatch_FreePattern(OSMatch *reg) v0.1
- * Release all the memory created by the compilation/executation
- * phases.
- * Returns void.
- */
+/* Release all the memory created by the compilation/execution phases */
 void OSMatch_FreePattern(OSMatch *reg)
 {
-    /* Freeing the patterns */
-    if(reg->patterns)
-    {
-        char **pattern = reg->patterns;
-        while(*pattern)
-        {
-            if(*pattern)
-                free(*pattern);
-            pattern++;    
-        }
-
-        free(reg->patterns);
-        free(reg->size);
-        free(reg->match_fp);
-
-        reg->patterns = NULL;
-        reg->size = NULL;
-        reg->match_fp = NULL;
+    /* 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;
     }
 
     return;
 }
 
-
-/* EOF */