Annotation of researchv10no/libpicfile/picputprop.c, revision 1.1.1.1

1.1       root        1: #include <picfile.h>
                      2: #include <stdio.h>
                      3: #include <libc.h>
                      4: /*
                      5:  * Bug: doesn't check status from malloc or realloc.
                      6:  */
                      7: PICFILE *picputprop(f, name, val)
                      8: PICFILE *f;
                      9: char *name, *val;
                     10: {
                     11:        register char **ap;
                     12:        int i, nlen=strlen(name), vlen=strlen(val), alen;
                     13:        for(i=0,ap=f->argv;i!=f->argc;i++,ap++)
                     14:                if(strncmp(*ap, name, nlen)==0 && (*ap)[nlen]=='='){
                     15:                        alen=strlen(*ap);
                     16:                        *ap=realloc(*ap, alen+vlen+2);
                     17:                        (*ap)[alen]='\n';
                     18:                        strcpy(*ap+alen+1, val);
                     19:                        return f;
                     20:                }
                     21:        f->argv=(char **)realloc((char *)f->argv, (f->argc+2)*sizeof(char *));
                     22:        ap=&f->argv[f->argc];
                     23:        *ap=malloc(nlen+vlen+2);
                     24:        strcpy(*ap, name);
                     25:        (*ap)[nlen]='=';
                     26:        strcpy(*ap+nlen+1, val);
                     27:        f->argv[++f->argc]=0;
                     28:        return f;
                     29: }

unix.superglobalmegacorp.com

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