fix: also lint internal header files
ci/woodpecker/pr/lint Pipeline was successful Details
ci/woodpecker/pr/test Pipeline was successful Details
ci/woodpecker/pr/test-mem Pipeline was successful Details

pull/5/head
Jef Roosens 2023-02-23 10:13:58 +01:00
parent d9402ced54
commit 38e84afd1d
Signed by: Jef Roosens
GPG Key ID: B75D4F293C7052DB
4 changed files with 37 additions and 34 deletions

View File

@ -11,7 +11,7 @@ INC_DIRS ?= include
LIB := $(BUILD_DIR)/$(LIB_FILENAME) LIB := $(BUILD_DIR)/$(LIB_FILENAME)
SRCS != find '$(SRC_DIR)' -iname '*.c' SRCS != find '$(SRC_DIR)' -iname '*.c'
SRCS_H != find $(INC_DIRS) -iname '*.h' SRCS_H != find $(INC_DIRS) '$(SRC_DIR)' -iname '*.h'
SRCS_TEST != find '$(TEST_DIR)' -iname '*.c' SRCS_TEST != find '$(TEST_DIR)' -iname '*.c'
OBJS := $(SRCS:%=$(BUILD_DIR)/%.o) OBJS := $(SRCS:%=$(BUILD_DIR)/%.o)
@ -66,15 +66,9 @@ $(TARGETS_TEST): test-%: %
$(TARGETS_MEM_TEST): test-mem-%: % $(TARGETS_MEM_TEST): test-mem-%: %
valgrind --tool=memcheck --error-exitcode=1 --track-origins=yes --leak-check=full ./$^ valgrind --tool=memcheck --error-exitcode=1 --track-origins=yes --leak-check=full ./$^
test-mem: build-test
@ $(foreach bin,$(BINS_TEST),valgrind --tool=memcheck --error-exitcode=1 \
--track-origins=yes --leak-check=full ./$(bin);)
.PHONY: build-test .PHONY: build-test
build-test: $(BINS_TEST) build-test: $(BINS_TEST)
# For simplicity, we link every object file to each of the test files. This
# might be changed later if this starts to become too slow.
$(BINS_TEST): %: %.c.o $(LIB) $(BINS_TEST): %: %.c.o $(LIB)
$(CC) \ $(CC) \
$^ -o $@ $^ -o $@

View File

@ -36,7 +36,8 @@ void vieter_heap_tree_free(vieter_heap_node *root);
* Given the roots of the smallest trees in two heaps, merge them into a single * Given the roots of the smallest trees in two heaps, merge them into a single
* large heap. * large heap.
*/ */
vieter_heap_node *vieter_heap_tree_merge(vieter_heap_node *root_a, vieter_heap_node *root_b); vieter_heap_node *vieter_heap_tree_merge(vieter_heap_node *root_a,
vieter_heap_node *root_b);
/* /*
* Given the roots of two trees of the same order, merge them into a heap of one * Given the roots of two trees of the same order, merge them into a heap of one

View File

@ -2,8 +2,8 @@
#define VIETER_TREE_NODE #define VIETER_TREE_NODE
#include "vieter_tree.h" #include "vieter_tree.h"
#include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h>
typedef enum vieter_tree_node_flag { typedef enum vieter_tree_node_flag {
vieter_tree_node_black = ((uint8_t)1) << 0, vieter_tree_node_black = ((uint8_t)1) << 0,
@ -33,27 +33,33 @@ void vieter_tree_node_free(vieter_tree_node *node);
/* /*
* Insert a new key into the given tree. * Insert a new key into the given tree.
*/ */
vieter_tree_error vieter_tree_node_insert(vieter_tree_node *root, uint64_t key, void *data); vieter_tree_error vieter_tree_node_insert(vieter_tree_node *root, uint64_t key,
void *data);
/* /*
* Return the node representing the requested value. * Return the node representing the requested value.
*/ */
vieter_tree_error vieter_tree_node_search_node(vieter_tree_node **out, vieter_tree_node *root, uint64_t key); vieter_tree_error vieter_tree_node_search_node(vieter_tree_node **out,
vieter_tree_node *root,
uint64_t key);
/* /*
* Search for the data represented by the given key. * Search for the data represented by the given key.
*/ */
vieter_tree_error vieter_tree_node_search(void **out, vieter_tree_node *root, uint64_t key); vieter_tree_error vieter_tree_node_search(void **out, vieter_tree_node *root,
uint64_t key);
/* /*
* Remove the data associated with the given key. * Remove the data associated with the given key.
*/ */
vieter_tree_error vieter_tree_node_remove(void **out, vieter_tree_node **root_ptr, uint64_t key); vieter_tree_error
vieter_tree_node_remove(void **out, vieter_tree_node **root_ptr, uint64_t key);
/* /*
* Set a node's bit flag to the given value. * Set a node's bit flag to the given value.
*/ */
void vieter_tree_node_set(vieter_tree_node *node, vieter_tree_node_flag flag, bool value); void vieter_tree_node_set(vieter_tree_node *node, vieter_tree_node_flag flag,
bool value);
/* /*
* Get whether a node's bit flag is set. * Get whether a node's bit flag is set.
@ -70,12 +76,14 @@ void vieter_tree_node_add_child(vieter_tree_node *parent, uint64_t key,
/* /*
* Replace a node's children array. * Replace a node's children array.
*/ */
void vieter_tree_node_set_children(vieter_tree_node *parent, vieter_tree_node **children); void vieter_tree_node_set_children(vieter_tree_node *parent,
vieter_tree_node **children);
/* /*
* Set a node's left or right child to the given node. * Set a node's left or right child to the given node.
*/ */
void vieter_tree_node_set_child(vieter_tree_node *parent, vieter_tree_node *child, bool right); void vieter_tree_node_set_child(vieter_tree_node *parent,
vieter_tree_node *child, bool right);
/* /*
* Return the in-order successor of the given node, or NULL if it's the last * Return the in-order successor of the given node, or NULL if it's the last