Annotation of coherent/b/lib/libc/gen/malloc/memok.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * libc/gen/malloc/memok.c
                      3:  * Test for corruption of malloc arena.
                      4:  * Assumes contiguous allocation from __a_first to __a_top.
                      5:  */
                      6: 
                      7: #include <stdio.h>
                      8: #include <sys/malloc.h>
                      9: 
                     10: /*
                     11:  * Return 1 if malloc arena is ok,
                     12:  * 0 if it is corrupted.
                     13:  */
                     14: int
                     15: memok()
                     16: {
                     17:        register MBLOCK *mp;
                     18:        unsigned counter, flag, len;
                     19: 
                     20:        if (NULL == (mp = __a_first))
                     21:                return ((NULL == __a_scanp) && !__a_count);
                     22:        flag = 0;
                     23:        for (counter = __a_count; counter--; ) {
                     24:                if (mp == __a_scanp)
                     25:                        flag++;
                     26:                if ((mp >= __a_top) || (mp < __a_first))
                     27:                        return 0;       /* out of bounds */
                     28:                mp = (len = realsize(mp->blksize)) ? bumpp(mp, len) : mp->uval.next;
                     29:        }
                     30:        return ((1 == flag) && (mp == __a_first));
                     31: }
                     32: 
                     33: /* end of memok.c */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.