diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000000000000000000000000000000000000..010ee3e02a53a5d1c401e2733145b49437430df1 --- /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 6f2bba0aa6ec101ad77c6e6b238ed5960eacafbd..ed05710c8227c956f42f3311c23d230ecfa6f62c 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 302903f8bfd826b8ab38ff22fae0b5c52569c62f..bbfef5215c310b291485fb88163f52566c33df7e 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 b83a7d3c0e8f5e078ae9e2131300554ab50b5492..4dc6314ae334142325869e7922ca0db89af17887 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; +}