diff options
| -rw-r--r-- | src/Makefile | 31 | ||||
| -rw-r--r-- | src/ll.c | 6 | ||||
| -rw-r--r-- | src/ll.h | 17 |
3 files changed, 35 insertions, 19 deletions
diff --git a/src/Makefile b/src/Makefile index c5a08c7..4bddadf 100644 --- a/src/Makefile +++ b/src/Makefile | |||
| @@ -1,22 +1,18 @@ | |||
| 1 | CC = gcc | 1 | CC = gcc |
| 2 | SHELL = /usr/bin/bash | 2 | SHELL = /usr/bin/env -S bash |
| 3 | 3 | ||
| 4 | DEBUG_CFLAGS := -fanalyzer -Wanalyzer-too-complex -ggdb -g3 -O0 | 4 | # I need to get better at makefiles so I can write this in a way that isn't absolutely insane/stupid |
| 5 | RELEASE_CFLAGS := -O3 -fipa-pta -fipa-cp -fuse-linker-plugin -flto=auto | 5 | # RELEASE_CFLAGS := -O3 -fipa-pta -fipa-cp -fuse-linker-plugin -flto=auto |
| 6 | CFLAGS = -Wall -Wextra -Wpedantic -pedantic-errors $(DEBUG_CFLAGS) $$(pkg-config --cflags libsodium) | 6 | # RELEASE_LDFLAGS := -fuse-linker-plugin -flto=auto |
| 7 | 7 | ||
| 8 | DEBUG_LDLIBS := | 8 | CFLAGS = -Wall -Wextra -Wpedantic -pedantic-errors -fanalyzer -Wanalyzer-too-complex -ggdb -g3 -O0 $$(pkg-config --cflags libsodium) |
| 9 | RELEASE_LDLIBS := | 9 | LDLIBS += $$(pkg-config --libs-only-l libsodium) |
| 10 | LDLIBS += $(DEBUG_LDLIBS) $$(pkg-config --libs-only-l libsodium) | 10 | LDFLAGS += $$(pkg-config --libs-only-L libsodium) |
| 11 | 11 | ||
| 12 | DEBUG_LDFLAGS := | ||
| 13 | RELEASE_LDFLAGS := -fuse-linker-plugin -flto=auto | ||
| 14 | LDFLAGS += $(DEBUG_LDFLAGS) $$(pkg-config --libs-only-L libsodium) | ||
| 15 | 12 | ||
| 13 | BINARIES := main | ||
| 16 | 14 | ||
| 17 | BINARIES := main encryption | 15 | .PHONY: all c clean val |
| 18 | |||
| 19 | .PHONY: all clean | ||
| 20 | 16 | ||
| 21 | all: main | 17 | all: main |
| 22 | 18 | ||
| @@ -27,8 +23,9 @@ main.o: main.c shared.h | |||
| 27 | arena.o: arena.c arena.h shared.h | 23 | arena.o: arena.c arena.h shared.h |
| 28 | shared.o: shared.c shared.h | 24 | shared.o: shared.c shared.h |
| 29 | 25 | ||
| 30 | encryption: encryption.c encryption.h shared.o shared.h | ||
| 31 | ll: ll.o shared.o | ||
| 32 | |||
| 33 | c clean: | 26 | c clean: |
| 34 | rm -rvf $(BINARIES) $(wildcard *.o) $(wildcard *.test*) $(wildcard *.enc) \ No newline at end of file | 27 | rm -rvf $(BINARIES) $(wildcard *.o) $(wildcard *.test*) $(wildcard *.enc) |
| 28 | |||
| 29 | val: | ||
| 30 | $(MAKE) all | ||
| 31 | valgrind --leak-check=yes ./main \ No newline at end of file | ||
| @@ -4,6 +4,7 @@ | |||
| 4 | #include <stddef.h> | 4 | #include <stddef.h> |
| 5 | #include <stdlib.h> | 5 | #include <stdlib.h> |
| 6 | #include <errno.h> | 6 | #include <errno.h> |
| 7 | #include <error.h> | ||
| 7 | 8 | ||
| 8 | typedef struct dll { | 9 | typedef struct dll { |
| 9 | void *data; | 10 | void *data; |
| @@ -118,7 +119,8 @@ int dlinkedlist_xxxend(dlinkedlist * const ll, void *data, dll_freecb fcb, char | |||
| 118 | break; | 119 | break; |
| 119 | 120 | ||
| 120 | default: | 121 | default: |
| 121 | abort(); | 122 | XALLOC_EXIT("<dlinkedlist_xxxend> got an invalid op token when it shouldn't be possible to recieve one"); |
| 123 | // Technically not an alloc, but also there's no reason I can't reuse a perfectly good macro | ||
| 122 | } | 124 | } |
| 123 | 125 | ||
| 124 | ll->size++; | 126 | ll->size++; |
| @@ -172,7 +174,7 @@ int dlinkedlist_insert(dlinkedlist * const ll, void *data, dll_freecb fcb, int i | |||
| 172 | dllnode *new = dllnode_init(data, fcb); | 174 | dllnode *new = dllnode_init(data, fcb); |
| 173 | dllnode *current = dlinkedlist_getnode(ll, index); | 175 | dllnode *current = dlinkedlist_getnode(ll, index); |
| 174 | if(!current) | 176 | if(!current) |
| 175 | abort(); | 177 | XALLOC_EXIT("<dlinkedlist_insert> somehow managed to pull a null node from dlinkedlist_getnode(... , ... , ... , %d)", , (index)); |
| 176 | 178 | ||
| 177 | current->prev->next = new; | 179 | current->prev->next = new; |
| 178 | new->prev = current->prev; | 180 | new->prev = current->prev; |
| @@ -1,6 +1,23 @@ | |||
| 1 | #ifndef __VXGG_REWRITE___LL_H___305861098005___ | 1 | #ifndef __VXGG_REWRITE___LL_H___305861098005___ |
| 2 | #define __VXGG_REWRITE___LL_H___305861098005___ | 2 | #define __VXGG_REWRITE___LL_H___305861098005___ |
| 3 | 3 | ||
| 4 | /*////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 5 | // BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WA // | ||
| 6 | // RNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING // | ||
| 7 | // BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WA // | ||
| 8 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*//* | ||
| 9 | // // | ||
| 10 | // dlinkedlist functions should be considered X_ALLOC functions, as they call xcalloc to initialize new nodes. This is not // | ||
| 11 | // reflected in their naming, which could change later, but as of know it is something to keep in mind. This means ABSOLUETLY NO // | ||
| 12 | // USE OF DLINKEDLIST FUNCTIONS INSIDE ENCRYPTION FUNCTIONS, OR ANYTHING THAT SHOULD BE CONSIDERED ATOMIC OR SEMI-ATOMIC. IF // | ||
| 13 | // XCALLOC ERRORS FOR ANY REASON, AND YOU'RE DOING SOMETHING WITH THESE IN AN (SEMI)ATOMIC FUNCTION, YOU WILL BREAK SHIT // | ||
| 14 | // // | ||
| 15 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*//* | ||
| 16 | // BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WA // | ||
| 17 | // RNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING // | ||
| 18 | // BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WA // | ||
| 19 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/ | ||
| 20 | |||
| 4 | typedef int (*dll_freecb)(void*); | 21 | typedef int (*dll_freecb)(void*); |
| 5 | typedef struct dlinked dlinkedlist; | 22 | typedef struct dlinked dlinkedlist; |
| 6 | 23 | ||
