wip
This commit is contained in:
@ -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);
|
||||
```
|
||||
|
15
docs/math.md
15
docs/math.md
@ -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);
|
||||
```
|
||||
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user