-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbrktest.c
More file actions
39 lines (29 loc) · 677 Bytes
/
brktest.c
File metadata and controls
39 lines (29 loc) · 677 Bytes
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
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <comp421/yalnix.h>
#include <comp421/hardware.h>
int
main()
{
void *currbreak;
char *new;
(void)new;
currbreak = sbrk(0);
fprintf(stderr, "sbrk(0) = %p\n", currbreak);
currbreak = (void *)UP_TO_PAGE(currbreak);
currbreak++;
currbreak = (void *)UP_TO_PAGE(currbreak);
if (Brk(currbreak)) {
fprintf(stderr, "Brk %p returned error\n", currbreak);
Exit(1);
}
currbreak++;
currbreak = (void *)UP_TO_PAGE(currbreak);
if (Brk(currbreak)) {
fprintf(stderr, "Brk %p returned error\n", currbreak);
Exit(1);
}
new = malloc(10000);
Exit(0);
}