Skip to content

Commit 4f6e186

Browse files
committed
Did the following...
- build.sh formatting - darr.c is now just darr.h (header only) - fixed formatting of src/*
1 parent 18e1fb6 commit 4f6e186

File tree

8 files changed

+187
-209
lines changed

8 files changed

+187
-209
lines changed

build.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@
2424

2525

2626
# Default env vars
27-
if [ -z "$debug" ]; then debug=0; fi
28-
if [ -z "$debug_coverage" ]; then debug_coverage=0; fi
29-
if [ -z "$GCC" ]; then GCC="gcc"; fi
30-
if [ -z "$AR" ]; then AR="ar"; fi
31-
if [ -z "$MAKE" ]; then MAKE="make"; fi
32-
if [ -z "$GCC_VER" ]; then GCC_VER=gnu99; fi
27+
if [ -z "$debug" ]; then debug=0; fi
28+
if [ -z "$debug_coverage" ]; then debug_coverage=0; fi
29+
if [ -z "$GCC" ]; then GCC="gcc"; fi
30+
if [ -z "$AR" ]; then AR="ar"; fi
31+
if [ -z "$MAKE" ]; then MAKE="make"; fi
32+
if [ -z "$GCC_VER" ]; then GCC_VER=gnu99; fi
3333

3434

3535
# On help message request

src/darr.c

Lines changed: 0 additions & 40 deletions
This file was deleted.

src/darr.h

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <stdlib.h>
2727
#include <string.h>
2828

29+
2930
typedef struct tagArray {
3031
size_t size;
3132
size_t cap;
@@ -35,6 +36,30 @@ typedef struct tagArray {
3536
} Array;
3637

3738

39+
40+
static inline Array* array_new(size_t init_size, size_t increment, size_t type_size) {
41+
Array* arr = malloc(sizeof(Array));
42+
if(arr == 0)
43+
return 0;
44+
arr->size = 0;
45+
arr->cap = init_size;
46+
arr->increment = increment;
47+
arr->type_size = type_size;
48+
arr->data = malloc(init_size * sizeof(void*));
49+
if(arr->data == 0) {
50+
free(arr);
51+
return 0;
52+
}
53+
return arr;
54+
}
55+
56+
static inline void array_free(void* arr) {
57+
Array* a = (Array*) arr;
58+
free(a->data);
59+
free(a);
60+
}
61+
62+
3863
static int array_ensure_size(Array* arr, size_t size) {
3964
if(arr->size + size >= arr->cap) {
4065
arr->data = realloc(arr->data, (arr->cap + arr->increment) * sizeof(void*));
@@ -46,15 +71,6 @@ static int array_ensure_size(Array* arr, size_t size) {
4671
}
4772

4873

49-
Array* array_new(size_t init_size, size_t increment, size_t type_size);
50-
51-
static inline void array_free(void* arr) {
52-
Array* a = (Array*) arr;
53-
free(a->data);
54-
free(a);
55-
}
56-
57-
5874
static inline int array_push(Array* arr, void* data) {
5975
if(array_ensure_size(arr, 1) == 0)
6076
return 0;

0 commit comments

Comments
 (0)