revolutionize c or whatever
This commit is contained in:
commit
e0e6bad67e
4 changed files with 96 additions and 0 deletions
BIN
examples/a.out
Executable file
BIN
examples/a.out
Executable file
Binary file not shown.
28
examples/ll.c
Normal file
28
examples/ll.c
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#define MEMSAFE_PLEASE
|
||||
#include "memsafe.h"
|
||||
|
||||
typedef struct LLNode {
|
||||
int dat;
|
||||
struct LLNode *next;
|
||||
} LLNode;
|
||||
|
||||
int main(void) {
|
||||
memsafe_pushhist;
|
||||
LLNode *root = safemalloc(sizeof(LLNode));
|
||||
root->dat = 0;
|
||||
|
||||
LLNode *curr = root;
|
||||
|
||||
for (int i = 1; i < 1000; ++i) {
|
||||
LLNode *next = safemalloc(sizeof(LLNode));
|
||||
curr->next = next;
|
||||
next->dat = i;
|
||||
curr = next;
|
||||
}
|
||||
|
||||
root = NULL;
|
||||
memsafe_pophist;
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue