11 #define M ((unsigned)-1>>1)
22 unsigned long total
= 0;
24 for(i
=0, sz
=256 ; i
<32; i
++, sz
= ((sz
<< 1) | (sz
& V
)) & M
)
26 ptr2
= (struct s
*) malloc(sz
-sizeof(int));
27 printf("%2d(%8u)..%08lx..%ld\n",i
,sz
,(long)ptr2
,(long)ptr2
);
44 ptr2
= (struct s
*) malloc(sz
-sizeof(int));
45 if(ptr2
==0) { sz
>>=1; continue; }
46 printf("%2d(%8u)..%08lx..%ld\n",i
++,sz
,(long)ptr2
,(long)ptr2
);
60 printf("Free all - total was %ldK bytes\n", total
/1024);
67 ptr2
= (struct s
*) malloc(200);
68 printf("%2d(%8u)..%08lx..%ld\n",i
++,200,(long)ptr2
,(long)ptr2
);
69 ptr2
= (struct s
*) malloc(30000);
70 printf("%2d(%8u)..%08lx..%ld\n",i
++,30000,(long)ptr2
,(long)ptr2
);
71 ptr2
= (struct s
*) malloc(20000);
72 printf("%2d(%8u)..%08lx..%ld\n",i
++,20000,(long)ptr2
,(long)ptr2
);
73 sz
= (256<<sizeof(int));
76 ptr2
= (struct s
*) malloc(sz
-sizeof(int));
77 printf("%2d(%8u)..%08lx..%ld\n",i
++,sz
,(long)ptr2
,(long)ptr2
);
79 while(ptr2
&& i
< 100);