-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
libscary: An (scary) scalable array library in C | ||
================================================ | ||
|
||
This is one of those rotten dynamic array libraries, but wait, just take a look. | ||
|
||
```c | ||
int *a = scary_new(sizeof(int)); | ||
``` | ||
Look at this LHS; it looks like an ordinary C array, but | ||
|
||
```c | ||
printf("length: %zu\n", scary_length(a)); | ||
``` | ||
they knows their length by themselves 😱. | ||
```c | ||
scary_push(a, -1); | ||
scary_push(a, 42); | ||
``` | ||
You can push elements with automatic memory extension, | ||
as much as you want. | ||
|
||
And you'll see magic here: | ||
|
||
```c | ||
int i = a[1]; | ||
``` | ||
You can read/write them as an ordinary C array without any overhead 😱😱. | ||
|
||
```c | ||
printf("content: %d\n", i); | ||
``` | ||
Then it prints `42`. Happy ending. 🤔 |