Instead of retrieving the contents of a (possibly dynamically allocated) buffer
and then allocating new space for a copy, we can simply take ownership of the
original buffer. This saves an extra unnecessary allocation.
asize += 10;
argv = ALLOC(asize, argv, char *);
}
- argv[argc++] = strdup(agxbuse(&xbuf));
+ argv[argc++] = agxbdisown(&xbuf);
}
agxbfree(&xbuf);
{
fitem *fi = NEW(fitem);
- fi->ti.str = strdup(agxbuse(ag));
+ fi->ti.str = agxbdisown(ag);
fi->ti.font = HTMLstate.fontstack->cfont;
dtinsert(HTMLstate.fitemList, fi);
}
}
agxbputc(&xb, c);
}
- ns = strdup (agxbuse(&xb));
+ ns = agxbdisown(&xb);
agxbfree(&xb);
return ns;
}
agxbputc(&xb, (v & 0x3F) | 0x80);
}
}
- ns = strdup (agxbuse(&xb));
+ ns = agxbdisown(&xb);
agxbfree(&xb);
return ns;
}
agxbputc(&xb, outc);
}
}
- ns = strdup (agxbuse(&xb));
+ ns = agxbdisown(&xb);
agxbfree(&xb);
return ns;
}
}
}
}
- return strdup(agxbuse(xb2));
+ return agxbdisown(xb2);
}
}
return NULL;