diff options
author | pommicket <pommicket@gmail.com> | 2023-09-07 12:29:24 -0400 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2023-09-07 12:29:24 -0400 |
commit | 7b8b4d4495164250c71582347dd0338d387c4e98 (patch) | |
tree | b866ecb85c9c8072a3fbc22e2c4d1f5db6598536 /development.md | |
parent | 8cfcfb6309c0399c3e5e491695086d4723bfbc72 (diff) |
updat development.md, todo list
Diffstat (limited to 'development.md')
-rw-r--r-- | development.md | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/development.md b/development.md index 205c843..fc23ee5 100644 --- a/development.md +++ b/development.md @@ -11,6 +11,29 @@ The big `Ted` struct has basically all of the data for ted. In general, fixed-size types such as `u32` should be preferred to `unsigned int` & co. +ted makes heavy use of “dynamic arrays” (basically, `std::vector` for C, +inspired by [stb_ds.h](https://github.com/nothings/stb/blob/master/stb_ds.h)) — +check out the `arr_*` functions in `ds.h`. Basic usage is like: + +```c +int *array = NULL; +for (int i = 0; i < 5; i++) { + arr_add(array, i); +} +arr_foreach_ptr(array, int, p) { + *p *= 2; +} +// prints 5 6 +printf("%d %d\n", arr_len(array), array[3]); +// prints the numbers 0, 2, 4, 6, 8 +arr_foreach_ptr(array, int, p) { + printf("%d\n", *p); +} +arr_free(array); +``` + +(the secret is that the length/capacity of the array is stored at `array[-8..-1]` so that +indexing works as expected.) ## Files |