Annotation of coherent/a/usr/man/MULTI/notmem, revision 1.1.1.1

1.1       root        1: 
                      2: 
                      3: notmem()             General Function (libc)             notmem()
                      4: 
                      5: 
                      6: 
                      7: 
                      8: Check if memory is allocated
                      9: 
                     10: iinntt nnoottmmeemm(_p_t_r);
                     11: cchhaarr *_p_t_r;
                     12: 
                     13: notmem checks  if a  memory block  has been allocated  by calloc,
                     14: malloc, or realloc.  ptr points to the block to be checked.
                     15: 
                     16: notmem searches the arena for ptr.   It returns one if ptr is not
                     17: a memory block obtained from malloc, calloc, or realloc, and zero
                     18: if it is.
                     19: 
                     20: ***** Example *****
                     21: 
                     22: The following  example prints  a string, and  frees it if  it was
                     23: malloc'd.
                     24: 
                     25: 
                     26: #include <sys/malloc.h>
                     27: 
                     28: 
                     29: 
                     30: pfree(s)
                     31: char *s;
                     32: {
                     33:         printf("%s\n", s);
                     34:         if(!notmem(s))
                     35:                 free(s);
                     36: }
                     37: 
                     38: 
                     39: 
                     40: main()
                     41: {
                     42:         char *mallocked_string;
                     43:         char notmallocked_string[50];
                     44: 
                     45: 
                     46: 
                     47:         if ((mallocked_string = malloc(50)) == NULL)
                     48:                 exit(1);
                     49: 
                     50: 
                     51: 
                     52:         strcpy(mallocked_string, "This is a malloc'd string");
                     53:         strcpy(notmallocked_string, "This is not a malloc'd string");
                     54: 
                     55: 
                     56: 
                     57:         pfree(mallocked_string);
                     58:         pfree(notmallocked_string);
                     59: }
                     60: 
                     61: 
                     62: 
                     63: 
                     64: COHERENT Lexicon                                           Page 1
                     65: 
                     66: 
                     67: 
                     68: 
                     69: notmem()             General Function (libc)             notmem()
                     70: 
                     71: 
                     72: 
                     73: 
                     74: ***** See Also *****
                     75: 
                     76: arena, calloc(), free(),  general functions, malloc(), realloc(),
                     77: setbuf()
                     78: 
                     79: 
                     80: 
                     81: 
                     82: 
                     83: 
                     84: 
                     85: 
                     86: 
                     87: 
                     88: 
                     89: 
                     90: 
                     91: 
                     92: 
                     93: 
                     94: 
                     95: 
                     96: 
                     97: 
                     98: 
                     99: 
                    100: 
                    101: 
                    102: 
                    103: 
                    104: 
                    105: 
                    106: 
                    107: 
                    108: 
                    109: 
                    110: 
                    111: 
                    112: 
                    113: 
                    114: 
                    115: 
                    116: 
                    117: 
                    118: 
                    119: 
                    120: 
                    121: 
                    122: 
                    123: 
                    124: 
                    125: 
                    126: 
                    127: 
                    128: 
                    129: 
                    130: COHERENT Lexicon                                           Page 2
                    131: 
                    132: 

unix.superglobalmegacorp.com

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