]>
git.ipfire.org Git - thirdparty/systemd.git/blob - klibc/klibc/tests/malloctest2.c
13 struct slot s
[NSLOTS
];
18 char *p
, *ep
, *q
, *eq
;
23 for ( r
= 0 ; r
< NCYCLES
; r
++ ) {
24 i
= lrand48() % NSLOTS
;
28 printf("Freed %8zu bytes at %p\n", s
[i
].size
, s
[i
].ptr
);
32 sp
= lrand48(); /* 32-bit random number */
33 sp
>>= 12+(lrand48() % 20);
36 s
[i
].ptr
= p
= malloc(sp
);
39 for ( j
= 0 ; j
< NSLOTS
; j
++ ) {
45 if ( (p
< q
&& ep
> q
) || (p
>= q
&& p
< eq
) ) {
52 printf("Allocated %8zu bytes at %p, ok = %d\n", sp
, p
, ok
);
55 memset(p
, 0xee, sp
); /* Poison this memory */