do {
if (cnt >= arrsize-1) {
arrsize += 512;
- if (str) str = (char**)realloc (str, arrsize*sizeof(char*));
- else str = (char**)malloc (arrsize*sizeof(char*));
+ str = realloc (str, arrsize*sizeof(char*));
if (!str) return GLOB_NOSPACE;
}
str[cnt] = (char*)malloc (strlen(libdir)+1+strlen(wfd.cFileName)+1);
static int tnan;
if (tnan < inpn) {
- if (!tnas) {
- if (!(tnas = malloc(sizeof(tna_t) * inpn)))
- return -1;
- } else {
- if (!(tnas = realloc(tnas, sizeof(tna_t) * inpn)))
- return -1;
- }
+ if (!(tnas = realloc(tnas, sizeof(tna_t) * inpn)))
+ return -1;
tnan = inpn;
}
tnas[0].t = 0;
{
if (newopn <= opn)
return;
- if (!ops) {
- if (!(ops = malloc(POINTSIZE * newopn))) {
- prerror("cannot malloc ops");
- longjmp(jbuf,1);
- }
- } else {
- if (!(ops = realloc(ops, POINTSIZE * newopn))) {
- prerror("cannot realloc ops");
- longjmp(jbuf,1);
- }
+ if (!(ops = realloc(ops, POINTSIZE * newopn))) {
+ prerror("cannot realloc ops");
+ longjmp(jbuf,1);
}
opn = newopn;
}
{
if (newpnln <= pnln)
return 0;
- if (!pnls) {
- if (!(pnls = malloc(POINTNLINKSIZE * newpnln))) {
- prerror("cannot malloc pnls");
- return -1;
- }
- if (!(pnlps = malloc(POINTNLINKPSIZE * newpnln))) {
- prerror("cannot malloc pnlps");
- return -1;
- }
- } else {
- if (!(pnls = realloc(pnls, POINTNLINKSIZE * newpnln))) {
- prerror("cannot realloc pnls");
- return -1;
- }
- if (!(pnlps = realloc(pnlps, POINTNLINKPSIZE * newpnln))) {
- prerror("cannot realloc pnlps");
- return -1;
- }
+ if (!(pnls = realloc(pnls, POINTNLINKSIZE * newpnln))) {
+ prerror("cannot realloc pnls");
+ return -1;
+ }
+ if (!(pnlps = realloc(pnlps, POINTNLINKPSIZE * newpnln))) {
+ prerror("cannot realloc pnlps");
+ return -1;
}
pnln = newpnln;
return 0;
{
if (newtrin <= trin)
return 0;
- if (!tris) {
- if (!(tris = malloc(TRIANGLESIZE * newtrin))) {
- prerror("cannot malloc tris");
- return -1;
- }
- } else {
- if (!(tris = realloc(tris, TRIANGLESIZE * newtrin))) {
- prerror("cannot realloc tris");
- return -1;
- }
+ if (!(tris = realloc(tris, TRIANGLESIZE * newtrin))) {
+ prerror("cannot realloc tris");
+ return -1;
}
trin = newtrin;
{
if (newdqn <= dq.pnlpn)
return 0;
- if (!dq.pnlps) {
- if (!
- (dq.pnlps = malloc(POINTNLINKPSIZE * newdqn))) {
- prerror("cannot malloc dq.pnls");
- return -1;
- }
- } else {
- if (!(dq.pnlps = realloc(dq.pnlps, POINTNLINKPSIZE * newdqn))) {
- prerror("cannot realloc dq.pnls");
- return -1;
- }
+ if (!(dq.pnlps = realloc(dq.pnlps, POINTNLINKPSIZE * newdqn))) {
+ prerror("cannot realloc dq.pnls");
+ return -1;
}
dq.pnlpn = newdqn;
return 0;
{
if (newopn <= opn)
return 0;
- if (!ops) {
- if (!(ops = malloc(POINTSIZE * newopn))) {
- prerror("cannot malloc ops");
- return -1;
- }
- } else {
- if (!(ops = realloc((void *) ops, POINTSIZE * newopn))) {
- prerror("cannot realloc ops");
- return -1;
- }
+ if (!(ops = realloc((void *) ops, POINTSIZE * newopn))) {
+ prerror("cannot realloc ops");
+ return -1;
}
opn = newopn;
#include <stdlib.h>
#include <pathplan/pathutil.h>
-#define ALLOC(size,ptr,type) (ptr? realloc(ptr,(size)*sizeof(type)):malloc((size)*sizeof(type)))
+#define ALLOC(size,ptr,type) realloc(ptr,(size)*sizeof(type))
Ppoly_t copypoly(Ppoly_t argpoly)
{