wip
All checks were successful
Test and Deploy / test (push) Successful in 12s
Test and Deploy / docs (push) Has been skipped

This commit is contained in:
2024-05-06 12:17:13 -07:00
parent a99d1d3784
commit 04e4d07e99
8 changed files with 58 additions and 48 deletions

View File

@ -61,3 +61,12 @@ for (int i = 0; i < 10; i++) {
}
free(pd);
```
## reallocarray
reallocarray is reimplemented for macOS because Apple doesn't expose their implementation. This is taken straight
from the OpenBSD source
```c
void *reallocarray(void *optr, size_t nmemb, size_t size);
```

View File

@ -57,3 +57,18 @@ Works the same as `bresenham()` but uses the `Point` struct instead of `int`
```c
Point *bresenham_p(Point p1, Point p2, size_t *sz);
```
## Comparison Functions
Comparison functions to compare two items. These functions must return `1` if `a > b`, `-1` if
`a < b`, or `0` if `a == b`. This follows the pattern defined by `compar` functions in the C standard
library, making these usuable in the standard sorting functions like `qsort`
```c
int compar_int(const void *a, const void *b);
int compar_char(const void *a, const void *b);
// Example
qsort(arr, arr_sz, sizeof(int), compar_int);
```

View File

@ -137,16 +137,6 @@ comparison function to compare the data in the vector. This function must return
const void *vec_max(const Vector *vec, int(*cmp)(const void *a, const void *b));
```
## Comparison Functions
Comparison functions to compare data in a vector. These functions must return `1` if `a > b`, `-1` if
`a < b`, or `0` if `a == b`.
```c
int vec_cmp_int(const void *a, const void *b);
int vec_cmp_char(const void *a, const void *b);
```
## Macros
### vec_at