base: Convert doGzipLoad to use std::string instead of *char
Change-Id: I28c9bf7853267686402b43be00f857914770f7a7
This commit is contained in:
@@ -64,13 +64,10 @@ doGzipLoad(int fd)
|
||||
return -1;
|
||||
}
|
||||
|
||||
size_t tmp_len = strlen(P_tmpdir);
|
||||
char *tmpnam = (char*) malloc(tmp_len + 20);
|
||||
strcpy(tmpnam, P_tmpdir);
|
||||
strcat(tmpnam, "/gem5-gz-obj-XXXXXX"); // concat 19 chars
|
||||
std::string tmpnam_str = std::string(P_tmpdir) + "/gem5-gz-obj-XXXXXX";
|
||||
char *tmpnam = const_cast<char*>(tmpnam_str.c_str());
|
||||
fd = mkstemp(tmpnam); // repurposing fd variable for output
|
||||
if (fd < 0) {
|
||||
free(tmpnam);
|
||||
gzclose(fdz);
|
||||
return fd;
|
||||
}
|
||||
@@ -78,8 +75,6 @@ doGzipLoad(int fd)
|
||||
if (unlink(tmpnam) != 0)
|
||||
warn("couldn't remove temporary file %s\n", tmpnam);
|
||||
|
||||
free(tmpnam);
|
||||
|
||||
auto buf = new uint8_t[blk_sz];
|
||||
int r; // size of (r)emaining uncopied data in (buf)fer
|
||||
while ((r = gzread(fdz, buf, blk_sz)) > 0) {
|
||||
|
||||
Reference in New Issue
Block a user