[En-Nut-Discussion] GenChar driver, GenCharOpen

Curtis Maloney cmaloney at cardgate.net
Thu Feb 4 08:16:55 CET 2010


I was browsing the genchar code today, and saw the following code:

static NUTFILE *GenCharOpen(NUTDEVICE * dev, CONST char *name, int mode, 
int acc)
{
     NUTFILE *fp = (NUTFILE *) (dev->dev_dcb);

     if ((fp = malloc(sizeof(NUTFILE))) == 0) {
         return NUTFILE_EOF; /* No memory. */
     }

     fp->nf_next = 0;
     fp->nf_dev = dev;
     fp->nf_fcb = 0;

     return fp;
}

Why does it set fp to dev->dev_dcb, only to then overwrite it with a malloc?

--
Curtis



More information about the En-Nut-Discussion mailing list