summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Makefile31
-rw-r--r--src/ll.c6
-rw-r--r--src/ll.h17
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 @@
1CC = gcc 1CC = gcc
2SHELL = /usr/bin/bash 2SHELL = /usr/bin/env -S bash
3 3
4DEBUG_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
5RELEASE_CFLAGS := -O3 -fipa-pta -fipa-cp -fuse-linker-plugin -flto=auto 5# RELEASE_CFLAGS := -O3 -fipa-pta -fipa-cp -fuse-linker-plugin -flto=auto
6CFLAGS = -Wall -Wextra -Wpedantic -pedantic-errors $(DEBUG_CFLAGS) $$(pkg-config --cflags libsodium) 6# RELEASE_LDFLAGS := -fuse-linker-plugin -flto=auto
7 7
8DEBUG_LDLIBS := 8CFLAGS = -Wall -Wextra -Wpedantic -pedantic-errors -fanalyzer -Wanalyzer-too-complex -ggdb -g3 -O0 $$(pkg-config --cflags libsodium)
9RELEASE_LDLIBS := 9LDLIBS += $$(pkg-config --libs-only-l libsodium)
10LDLIBS += $(DEBUG_LDLIBS) $$(pkg-config --libs-only-l libsodium) 10LDFLAGS += $$(pkg-config --libs-only-L libsodium)
11 11
12DEBUG_LDFLAGS :=
13RELEASE_LDFLAGS := -fuse-linker-plugin -flto=auto
14LDFLAGS += $(DEBUG_LDFLAGS) $$(pkg-config --libs-only-L libsodium)
15 12
13BINARIES := main
16 14
17BINARIES := main encryption 15.PHONY: all c clean val
18
19.PHONY: all clean
20 16
21all: main 17all: main
22 18
@@ -27,8 +23,9 @@ main.o: main.c shared.h
27arena.o: arena.c arena.h shared.h 23arena.o: arena.c arena.h shared.h
28shared.o: shared.c shared.h 24shared.o: shared.c shared.h
29 25
30encryption: encryption.c encryption.h shared.o shared.h
31ll: ll.o shared.o
32
33c clean: 26c 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
29val:
30 $(MAKE) all
31 valgrind --leak-check=yes ./main \ No newline at end of file
diff --git a/src/ll.c b/src/ll.c
index 4e018f2..1fa8773 100644
--- a/src/ll.c
+++ b/src/ll.c
@@ -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
8typedef struct dll { 9typedef 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;
diff --git a/src/ll.h b/src/ll.h
index 6e4ccf9..1f4b3b2 100644
--- a/src/ll.h
+++ b/src/ll.h
@@ -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
4typedef int (*dll_freecb)(void*); 21typedef int (*dll_freecb)(void*);
5typedef struct dlinked dlinkedlist; 22typedef struct dlinked dlinkedlist;
6 23