Annotation of researchv10no/cmd/odist/opkg/alloc.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  *     storage allocator
                      3:  *
                      4:  *     calls malloc or realloc and aborts if unsuccessful
                      5:  */
                      6: 
                      7: #include "asd.h"
                      8: #include <stdio.h>
                      9: #include <stdlib.h>
                     10: #include <string.h>
                     11: 
                     12: void *
                     13: alloc (size_t n)
                     14: {
                     15:        register void *p;
                     16: 
                     17:        p = malloc (n);
                     18:        schk (p);
                     19:        return p;
                     20: }
                     21: 
                     22: void *
                     23: ralloc (void *s, size_t n)
                     24: {
                     25:        register void *p;
                     26: 
                     27:        if (s == NULL)
                     28:                return alloc (n);
                     29:        
                     30:        p = realloc (s, n);
                     31:        schk (p);
                     32:        return p;
                     33: }
                     34: 
                     35: /* return a copy of a string */
                     36: char *
                     37: copy (char *s)
                     38: {
                     39:        register char *r;
                     40:        r = alloc (strlen (s) + 1);
                     41:        strcpy (r, s);
                     42:        return r;
                     43: }

unix.superglobalmegacorp.com

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