x = ilookup(name);
if(x->prefix == nil) {
x->prefix = prefix;
- x->def = def;
+ x->def = strdup(def);
x->file = file;
} else if(strcmp(x->prefix, prefix) != 0) {
fprint(2, "%s: conflicting definitions for %s\n", argv0, name);
fprint(2, "%s:\t%s %s %s\n", file, prefix, name, def);
nerrors++;
}
+ free(name);
+ free(def);
}
+ free(file);
}
// replace all "". with pkg.
n++;
if(n == 0)
- return t0;
+ return strdup(t0);
// use malloc, not mal, so that caller can free
w0 = malloc(strlen(t0) + strlen(pkg)*n);
Bseek(f, 0L, 0);
ldobj(f, pkg, l, file, FileObj);
Bterm(f);
+ free(pkg);
return;
}
out:
Bterm(f);
+ free(pkg);
}
void
magic = c1<<24 | c2<<16 | c3<<8 | c4;
if(magic == 0x7f454c46) { // \x7F E L F
ldelf(f, pkg, len, pn);
+ free(pn);
return;
}
if((magic&~1) == 0xfeedface || (magic&~0x01000000) == 0xcefaedfe) {
ldmacho(f, pkg, len, pn);
+ free(pn);
return;
}
if(c1 == 0x4c && c2 == 0x01 || c1 == 0x64 && c2 == 0x86) {
ldpe(f, pkg, len, pn);
+ free(pn);
return;
}
return;
}
diag("%s: not an object file", pn);
+ free(pn);
return;
}
// First, check that the basic goos, string, and version match.
- t = smprint("%s %s %s ", getgoos(), thestring, getgoversion());
+ t = smprint("%s %s %s ", goos, thestring, getgoversion());
line[n] = ' ';
if(strncmp(line+10, t, strlen(t)) != 0 && !debug['f']) {
line[n] = '\0';
diag("%s: object is [%s] expected [%s]", pn, line+10, t);
free(t);
+ free(pn);
return;
}
line[n] = '\0';
diag("%s: object is [%s] expected [%s]", pn, line+10, theline);
free(t);
+ free(pn);
return;
}
}
Bseek(f, import1, 0);
ldobj1(f, pkg, eof - Boffset(f), pn);
+ free(pn);
return;
eof:
diag("truncated object file: %s", pn);
+ free(pn);
}
static Sym*