]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Create hash_ops structure to free keys of type pcre2_code
authorQuentin Deslandes <qde@naccy.de>
Tue, 13 Sep 2022 15:14:52 +0000 (16:14 +0100)
committerQuentin Deslandes <qde@naccy.de>
Thu, 15 Dec 2022 09:57:39 +0000 (09:57 +0000)
src/shared/pcre2-util.c
src/shared/pcre2-util.h

index 998dab04910c847b784e8a6155becb70ebf08c4a..a2c8687cf906b829ca201e9cfb97f2d8374df689 100644 (file)
@@ -14,6 +14,15 @@ pcre2_code* (*sym_pcre2_compile)(PCRE2_SPTR, PCRE2_SIZE, uint32_t, int *, PCRE2_
 int (*sym_pcre2_get_error_message)(int, PCRE2_UCHAR *, PCRE2_SIZE);
 int (*sym_pcre2_match)(const pcre2_code *, PCRE2_SPTR, PCRE2_SIZE, PCRE2_SIZE, uint32_t, pcre2_match_data *, pcre2_match_context *);
 PCRE2_SIZE* (*sym_pcre2_get_ovector_pointer)(pcre2_match_data *);
+
+DEFINE_HASH_OPS_WITH_KEY_DESTRUCTOR(
+        pcre2_code_hash_ops_free,
+        pcre2_code,
+        (void (*)(const pcre2_code *, struct siphash*))trivial_hash_func,
+        (int (*)(const pcre2_code *, const pcre2_code*))trivial_compare_func,
+        sym_pcre2_code_free);
+#else
+const struct hash_ops pcre2_code_hash_ops_free = {};
 #endif
 
 int dlopen_pcre2(void) {
index 11f1d77f4f28d795ac81ff523862870769f1585e..f1e744d5774b62f1e1bea0a559ca7e77dc812442 100644 (file)
@@ -1,6 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
+#include "hash-funcs.h"
 #include "macro.h"
 
 #if HAVE_PCRE2
@@ -24,6 +25,8 @@ typedef struct {} pcre2_code;
 
 #endif
 
+extern const struct hash_ops pcre2_code_hash_ops_free;
+
 typedef enum {
         PATTERN_COMPILE_CASE_AUTO,
         PATTERN_COMPILE_CASE_SENSITIVE,