-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.c
49 lines (42 loc) · 928 Bytes
/
test.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#pragma warning(disable : 4996)
#include "spymem.h"
#include "lists.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <time.h>
#ifdef _WIN32
#include <windows.h>
#else
#include <unistd.h>
#endif
#ifdef _WIN32
#define sleep Sleep
#endif
#define debug(...) {\
fprintf(stderr, __VA_ARGS__);\
fflush(stderr);\
}
extern List* SP_heap;
int main() {
SP_start();
debug("%s\n", sprintheap(50));
char* f = (char*)smalloc(5);
strcpy(f, "test");
debug("\nf=smalloc(5).\n");
debug("%s\n", sprintheap(-1));
void* fr = smalloc(3);
debug("fr=smalloc(3).\n");
debug("%s\n", sprintheap(50));
sfree(fr);
debug("sfree(fr).\n");
debug("%s\n", sprintheap(50));
scalloc(2, 1);
debug("scalloc(2, 1).\n");
debug("%s\n", sprintheap(50));
f = srealloc(f, 6);
debug("f=srealloc(f, 6).\n");
debug("%s\n\n", sprintheap(50));
debug("reallocs.\n%s\n", sprintreall());
debug("frees.\n%s\n", sprintfree());
}