From 8987a31eb11d715bf89cca4ac160d6c5154328e0 Mon Sep 17 00:00:00 2001
From: Abivarman <abivarman.kandiah@etu.hesge.ch>
Date: Wed, 23 Feb 2022 11:56:12 +0100
Subject: [PATCH] Add Opaque struct and create function

---
 .vscode/settings.json |  6 ++++++
 header/vectors.h      |  7 ++++++-
 src/test_vectors.c    |  5 +++--
 src/vectors.c         | 15 +++++++++++++++
 4 files changed, 30 insertions(+), 3 deletions(-)
 create mode 100644 .vscode/settings.json

diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 0000000..010ee3e
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,6 @@
+{
+	"files.associations": {
+		"stdlib.h": "c",
+		"stdio.h": "c"
+	}
+}
\ No newline at end of file
diff --git a/header/vectors.h b/header/vectors.h
index 6f2bba0..ed05710 100644
--- a/header/vectors.h
+++ b/header/vectors.h
@@ -1,6 +1,6 @@
 /*
     Autheur		: Abivarman KANDIAH
-    Date		: 11/01/2022
+    Date		: 22/02/2022
     Fichier		: vectors.h
     Descritpion : Vectors functions header
 */
@@ -8,11 +8,16 @@
 #ifndef _VECTORS_H_
 #define _VECTORS_H_
 
+#define VECTOR_INIT_CAPACITY 4
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdint.h>
 #include <stdbool.h>
 
+typedef int type;
+typedef struct vector_* vector;
 
+vector vector_create();
 
 #endif
\ No newline at end of file
diff --git a/src/test_vectors.c b/src/test_vectors.c
index 302903f..bbfef52 100644
--- a/src/test_vectors.c
+++ b/src/test_vectors.c
@@ -11,7 +11,8 @@
 #include "../header/vectors.h"
 
 int main()
-{
-	
+{	
+	vector test = vector_create();
+
 	return 0;
 }
\ No newline at end of file
diff --git a/src/vectors.c b/src/vectors.c
index b83a7d3..4dc6314 100644
--- a/src/vectors.c
+++ b/src/vectors.c
@@ -7,4 +7,19 @@
 
 #include "../header/vectors.h"
 
+struct vector_ {
+    type *content; // actual content of the vector
+    int capacity; // capacity allocated
+    int length; // actual length
+};
 
+vector vector_create()
+{
+	vector vec = malloc(sizeof(*vec)); //!BUG POSSIBLE
+
+	vec->content = malloc(sizeof(type) * VECTOR_INIT_CAPACITY);
+	vec->capacity = VECTOR_INIT_CAPACITY;
+	vec->length = 0;
+
+	return vec;
+}
-- 
GitLab