-
Notifications
You must be signed in to change notification settings - Fork 31
/
Serv.pas
58 lines (51 loc) · 1.07 KB
/
Serv.pas
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
unit serv;
interface
procedure FreeList(var p : pchar; s : word);
function NewEList(var p : pointer; s : word; c : boolean) : pointer;
implementation
procedure FreeList;
var r,
d : pchar;
begin
while p <> nil do begin
r := p;
d := p + s - 4;
move(d^, p, 4);
freeMem(r, s);
end;
end;
function NextList(p : pchar; s : word) : pointer;
var r,
d : pchar;
begin
d := p + s - 4;
move(d^, r, 4);
NextList := r;
end;
function NewEList;
var r,
d : pchar;
n : pchar;
begin
if p = Nil then begin
getmem(p, s);
NewEList := p;
r := p;
FillChar(r^, s, #0);
end else begin
n := p;
while NextList(n, s) <> nil do begin
n := NextList(n, s);
end;
getmem(r, s);
FillChar(r^, s, #0);
d := n + s - 4;
move(r, d^, 4);
if c then begin
d := r + s - 8;
move(n, d^, 4);
end;
NewEList := r;
end;
end;
end.