home *** CD-ROM | disk | FTP | other *** search
- #include <osbind.h>
- void Bconws(char *s)
- {
- while (*s) Bconout(2, *s++);
- }
- #define LONG long
- #define WORD short
- /*
- * Prinl - print a long integer (32 bits)
- *
- */
- void printl(val)
- register LONG val;
- {
- register WORD j;
- register WORD div_idx;
- register WORD first;
- static LONG divisors[] = { 1000000000,100000000,10000000,1000000,
- 100000,10000, 1000, 100, 10, 1 };
- #define MAX_IDX 10
-
- if (val == 0)
- {
- Bconout(2, '0');
- return;
- }
- else if (val == -2147483648)
- {
- Bconws( "-2147483648");
- return;
- }
-
- if (val < 0L)
- {
- Bconout(2, '-');
- val = -val;
- }
-
- first = 0;
- for(div_idx = 0; div_idx < MAX_IDX; div_idx++)
- {
- if(((j = (WORD)(val / divisors[div_idx])) != 0) || first != 0)
- {
- Bconout(2, j + '0');
- first = 1;
- }
- val %= divisors[div_idx];
- }
-
- }
-
- main()
- {
- long size;
- long *buf, *first, *last = 0;
-
- while ((size = Malloc(-1L)) >= 8)
- {
- buf = Malloc(size);
- printl(size);
- Bconws("\tbytes free at ");
- printl(buf);
- Bconws("\r\n");
- if (last) *last = buf;
- else first = buf;
- last = buf;
- *buf = 0;
- }
- /* free all those buffers */
- buf = first;
- while (buf) {
- last = *buf;
- Mfree(buf);
- buf = last;
- }
- }
-