[En-Nut-Discussion] GenChar driver, GenCharOpen
Harald Kipp
harald.kipp at egnite.de
Thu Feb 4 10:52:54 CET 2010
Hi Curtis,
Curtis Maloney wrote:
> NUTFILE *fp = (NUTFILE *) (dev->dev_dcb);
>
> if ((fp = malloc(sizeof(NUTFILE))) == 0) {
> return NUTFILE_EOF; /* No memory. */
> }
...
> Why does it set fp to dev->dev_dcb, only to then overwrite it with a malloc?
Good question. ;-)
In this case the first assignment is superfluous.
There are indeed simple drivers, which use dev_dcb as a pointer to a
static NUTFILE descriptor. But in this case the descriptor is
dynamically created and dev_dcb can be used for other purposes.
Harald
More information about the En-Nut-Discussion
mailing list