From b46aad6df449445a9fc4aa7b32bd40005438e3f7 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 13 Apr 2024 14:18:05 +0200 Subject: Adding upstream version 2.9.5. Signed-off-by: Daniel Baumann --- src/ebtree.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 src/ebtree.c (limited to 'src/ebtree.c') diff --git a/src/ebtree.c b/src/ebtree.c new file mode 100644 index 0000000..db27875 --- /dev/null +++ b/src/ebtree.c @@ -0,0 +1,50 @@ +/* + * Elastic Binary Trees - exported generic functions + * Version 6.0.6 + * (C) 2002-2011 - Willy Tarreau + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, version 2.1 + * exclusively. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include + +void eb_delete(struct eb_node *node) +{ + __eb_delete(node); +} + +/* used by insertion primitives */ +struct eb_node *eb_insert_dup(struct eb_node *sub, struct eb_node *new) +{ + return __eb_insert_dup(sub, new); +} + +/* compares memory blocks m1 and m2 for up to bytes. Immediately stops at + * the first non-matching byte. It returns 0 on full match, non-zero otherwise. + * One byte will always be checked so this must not be called with len==0. It + * takes 2+5cy/B on x86_64 and is ~29 bytes long. + */ +int eb_memcmp(const void *m1, const void *m2, size_t len) +{ + const char *p1 = (const char *)m1 + len; + const char *p2 = (const char *)m2 + len; + ssize_t ofs = -len; + char diff; + + do { + diff = p1[ofs] - p2[ofs]; + } while (!diff && ++ofs); + return diff; +} -- cgit v1.2.3