Skip to content

Commit 7790987

Browse files
committed
da: add header documentation
1 parent 86b3ca7 commit 7790987

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

da.h

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,33 @@
88
#include <stddef.h>
99
#include <stdbool.h>
1010

11-
typedef struct {
11+
// Pre defined array types. Order of values should be same. size, capacity and
12+
// data. Names does not matter.
13+
typedef struct da_int {
1214
size_t size, capacity;
1315
int *data;
1416
} Da_Int;
15-
bool da_int_append(Da_Int *arr, int val);
16-
17-
typedef struct {
17+
typedef struct da_double {
1818
size_t size, capacity;
1919
double *data;
2020
} Da_Double;
21-
bool da_double_append(Da_Double *arr, double val);
22-
23-
typedef struct {
21+
typedef struct da_size {
2422
size_t size, capacity;
2523
size_t *data;
2624
} Da_Size;
27-
bool da_size_append(Da_Size *arr, size_t val);
28-
29-
typedef struct {
25+
typedef struct da_str {
3026
size_t size, capacity;
3127
const char **data;
3228
} Da_Str;
29+
30+
// append given value to the end of array, initializes if necessary, grows if necessary.
31+
bool da_int_append(Da_Int *arr, int val);
32+
bool da_double_append(Da_Double *arr, double val);
33+
bool da_size_append(Da_Size *arr, size_t val);
3334
bool da_str_append(Da_Str *arr, const char *val);
3435

36+
// You can create your own dynamic arrays with this helper functions.
37+
// See da.c for example implementations. You can also take a look at example.c.
3538
#define da_init_if_needed(arr) da_init_generic_if_needed((Da_Generic *)(arr), sizeof(*(arr)->data))
3639
#define da_grow_if_needed(arr) da_grow_generic_if_needed((Da_Generic *)(arr), sizeof(*(arr)->data))
3740
#define da_destroy(arr) da_destroy_generic((Da_Generic *)(arr))

0 commit comments

Comments
 (0)