PaCheckCompressed() removed API quirkiness
When constifying there is this inconsistent quirk in this API returning 'filename' or a malloced storage. When special handling needs to be made by the caller to detect this to decide if it needs a free. This appears to done to save a strdup(). Make it always return a malloc block so the API contract is strightforward to the caller. A non-NULL return requires free() by the caller.
This commit is contained in:
parent
e7bfa72298
commit
e22e5d63b9
|
|
@ -129,7 +129,7 @@ gzFile flock_zopen(filename, mode, is_locked, fdp)
|
||||||
|
|
||||||
fd = open(fname, oflag);
|
fd = open(fname, oflag);
|
||||||
if (fdp != NULL) *fdp = fd;
|
if (fdp != NULL) *fdp = fd;
|
||||||
if (fname != filename) freeMagic(fname);
|
freeMagic(fname);
|
||||||
return gzdopen(fd, mode);
|
return gzdopen(fd, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -196,7 +196,7 @@ gzFile flock_zopen(filename, mode, is_locked, fdp)
|
||||||
|
|
||||||
done:
|
done:
|
||||||
if (fdp != NULL) *fdp = fd;
|
if (fdp != NULL) *fdp = fd;
|
||||||
if (fname != filename) freeMagic(fname);
|
freeMagic(fname);
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
11
utils/path.c
11
utils/path.c
|
|
@ -70,10 +70,10 @@ bool FileLocking = TRUE;
|
||||||
* attempting to open the file.
|
* attempting to open the file.
|
||||||
*
|
*
|
||||||
* Return value:
|
* Return value:
|
||||||
* The string value that resulted in a valid file descriptor.
|
* The string value that resulted in a valid file descriptor
|
||||||
* This is a dynamically allocated string *or* a pointer to the
|
* (a file that could be opened using that filename).
|
||||||
* original filename; the calling routine should check and
|
* Return value is a dynamically allocated string the calling
|
||||||
* free if needed.
|
* routine should free.
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------
|
*-------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
@ -91,8 +91,7 @@ PaCheckCompressed(filename)
|
||||||
fd = open(gzname, O_RDONLY);
|
fd = open(gzname, O_RDONLY);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
{
|
{
|
||||||
freeMagic(gzname);
|
strcpy(gzname, filename); /* always shorter than allocation */
|
||||||
gzname = filename;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue