Browse Source

made file tree, made initial functions

Iver 1 month ago
commit
9f4cdf8f15
12 changed files with 97 additions and 0 deletions
  1. 16 0
      Makefile
  2. 0 0
      changelog.txt
  3. 1 0
      dbg
  4. 0 0
      issues.txt
  5. 6 0
      readme.md
  6. 1 0
      run
  7. 0 0
      src/headers/KT_functions.h
  8. 0 0
      src/headers/KT_types.h
  9. 8 0
      src/headers/kiyomitree.h
  10. 3 0
      src/launch program/main.c
  11. 61 0
      src/main/main.c
  12. 1 0
      val

+ 16 - 0
Makefile

@@ -0,0 +1,16 @@
+COMPILER=gcc
+FLAGS_ALL=-g -Wall -Wextra -Wno-unused-variable -Wno-unused-parameter
+FLAGS_EXAMPLE=-Lbuilds/ -lNAMEHERE -lLIBNAMEHERE -Wl,-rpath=builds/ -lm
+FLAGS_LIB=-fPIC -shared -lc -lm 
+
+main.bin: NAMEHERE.so LIBNAMEHERE.so
+	$(COMPILER) $(FLAGS_ALL) src/launch\ program/main.c -o builds/main.bin $(FLAGS_EXAMPLE) 
+
+NAMEHERE.so:
+	$(COMPILER) $(FLAGS_ALL) src/main/main.c -o builds/librasteriver.so $(FLAGS_LIB) 
+
+LIBNAMEHERE.so:
+	cp src/libraries/libLIBNAMEHERE.so builds/
+
+clean:
+	rm builds/*

+ 0 - 0
changelog.txt


+ 1 - 0
dbg

@@ -0,0 +1 @@
+gdb -ex run builds/main.bin

+ 0 - 0
issues.txt


+ 6 - 0
readme.md

@@ -0,0 +1,6 @@
+# KiyomiTree, A Dynamic Array Manager
+
+## Etymology
+
+ * Based off the name OrangeTree from my other repo because they do similar things
+ * A kiyomi is a kind of Japanese citrus

+ 1 - 0
run

@@ -0,0 +1 @@
+./builds/main.bin

+ 0 - 0
src/headers/KT_functions.h


+ 0 - 0
src/headers/KT_types.h


+ 8 - 0
src/headers/kiyomitree.h

@@ -0,0 +1,8 @@
+#ifndef KIYOMITREE_H
+#define KIYOMITREE_H
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+#endif

+ 3 - 0
src/launch program/main.c

@@ -0,0 +1,3 @@
+int main(){
+    return 0;
+}

+ 61 - 0
src/main/main.c

@@ -0,0 +1,61 @@
+#include "../headers/kiyomitree.h"
+
+void** KT_new_array(size_t element_count){
+    size_t* current_allocated_elements = malloc(sizeof(size_t));
+    *current_allocated_elements = element_count;
+
+    size_t* current_existing_elements = malloc(sizeof(size_t));
+    *current_existing_elements = 0;
+
+    void** array = malloc(sizeof(void*) * (element_count + 2));
+
+    array[0] = current_allocated_elements;
+    array[1] = current_existing_elements;
+
+    return array + 2;
+}
+
+void check_size(void** array){
+    size_t* current_allocated_elements = array[-2];
+    size_t* current_existing_elements = array[-1];
+    
+    if (*current_existing_elements >= *current_allocated_elements)
+        array = (void**)(realloc(array - 2, sizeof(void*) * (*current_allocated_elements * 2 + 2)) + 2);
+}
+
+void KT_append(void** array, void* pointer){    
+    check_size(array);
+
+    array[(*(size_t*)array[-1])++] = pointer;
+}
+
+void KT_prepend(void** array, void* pointer){    
+    (*(size_t*)array[-1])++;
+
+    check_size(array);
+
+    memcpy(array + 1, array, *(size_t*)array[-1] - 1);
+
+    array[0] = pointer;
+}
+
+void KT_insert_left(void** array, void* pointer, size_t index){
+    (*(size_t*)array[-1])++;
+
+    check_size(array);
+
+    memcpy(array + index + 1, array, *(size_t*)array[-1] - index - 1);
+
+    array[index] = pointer;
+}
+
+
+void KT_insert_right(void** array, void* pointer, size_t index){
+    (*(size_t*)array[-1])++;
+
+    check_size(array);
+
+    memcpy(array + index + 2, array, *(size_t*)array[-1] - index - 2);
+
+    array[index + 1] = pointer;
+}

+ 1 - 0
val

@@ -0,0 +1 @@
+valgrind --leak-check=full --track-origins=yes ./builds/main.bin