-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmalloc.c
More file actions
62 lines (58 loc) · 1.34 KB
/
Copy pathmalloc.c
File metadata and controls
62 lines (58 loc) · 1.34 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
struct map
{
char *m_size;
char *m_addr;
};
malloc(mp, size)
struct map *mp;
{
register int a;
register struct map *bp;
for (bp = mp; bp ->m_size;bp++){
if(bp->m_size >=size){
bp->m_addr =+size;
if((bp->m_size =-size)==0){
do{
bp++;
(bp-1)->m_addr =bp->m_addr;
}while((bp-1)->m_size = bp->m_size);
}
return a;
}
}
return 0;
};
mfree(mp,size, aa)
struct map *mp;
{
register struct map *bp;
register int t;
register int a;
a=aa;
for(bp=mp;bp->m_addr<=a &&bp->m_size!=0;bp++);
if(bp > mp && ((bp-1)->m_addr + (bp-1)->m_size==a)){
(bp-1)->m_size =+size;
if(a+size == bp->m_addr){
(bp-1)->m_size =+ bp->m_size;
while(bp->m_size){
bp++;
(bp-1)->m_size =bp->m_size;
(bp-1)->m_addr =bp->m_addr;
}
}
}else{
if(a + size ==bp->m_addr && bp->m_size){
bp->m_addr =- size;
bp->m_size =+ size;
}else if (size){
do{
t=bp->m_addr;
bp->m_addr=a;
a=t;
t=bp->m_size;
bp->m_size=size;
bp++;
}while(size = t);
}
}
}