Computer Scientist

Monday, 13 June 2011

Double pointer's usages (on going)

The first usage of the double pointer is to allocate memory for a given pointer:

         nlp = &res.readdir_res_u.list;
while (d = readdir(dirp)) {
nl = *nlp = (namenode *)malloc(sizeof(namenode));
nl->name = strdup(d->d_name);
nlp = &nl->pNext;
}
*nlp = NULL;

This comes from "Power Programming with RPC P84"