mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
windows.c: small cleaup in the wrapper functions
- use an already defined 'ret' value if available - don't put free() calls in NULL check branches (saves a line) Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
4096383fb5
commit
1481382617
1 changed files with 8 additions and 13 deletions
15
windows.c
15
windows.c
|
@ -176,7 +176,7 @@ int subsurface_rename(const char *path, const char *newpath)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
if (!path || !newpath)
|
if (!path || !newpath)
|
||||||
return -1;
|
return ret;
|
||||||
|
|
||||||
wchar_t *wpath = utf8_to_utf16(path);
|
wchar_t *wpath = utf8_to_utf16(path);
|
||||||
wchar_t *wnewpath = utf8_to_utf16(newpath);
|
wchar_t *wnewpath = utf8_to_utf16(newpath);
|
||||||
|
@ -192,14 +192,12 @@ int subsurface_open(const char *path, int oflags, mode_t mode)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
if (!path)
|
if (!path)
|
||||||
return -1;
|
return ret;
|
||||||
wchar_t *wpath = utf8_to_utf16(path);
|
wchar_t *wpath = utf8_to_utf16(path);
|
||||||
if (wpath) {
|
if (wpath)
|
||||||
ret = _wopen(wpath, oflags, mode);
|
ret = _wopen(wpath, oflags, mode);
|
||||||
free((void *)wpath);
|
free((void *)wpath);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE *subsurface_fopen(const char *path, const char *mode)
|
FILE *subsurface_fopen(const char *path, const char *mode)
|
||||||
|
@ -215,9 +213,8 @@ FILE *subsurface_fopen(const char *path, const char *mode)
|
||||||
wmode[i] = (wchar_t)mode[i];
|
wmode[i] = (wchar_t)mode[i];
|
||||||
wmode[len] = 0;
|
wmode[len] = 0;
|
||||||
ret = _wfopen(wpath, wmode);
|
ret = _wfopen(wpath, wmode);
|
||||||
free((void *)wpath);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
free((void *)wpath);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,12 +225,10 @@ void *subsurface_opendir(const char *path)
|
||||||
if (!path)
|
if (!path)
|
||||||
return ret;
|
return ret;
|
||||||
wchar_t *wpath = utf8_to_utf16(path);
|
wchar_t *wpath = utf8_to_utf16(path);
|
||||||
if (wpath) {
|
if (wpath)
|
||||||
ret = _wopendir(wpath);
|
ret = _wopendir(wpath);
|
||||||
free((void *)wpath);
|
free((void *)wpath);
|
||||||
return (void *)ret;
|
return (void *)ret;
|
||||||
}
|
|
||||||
return (void *)ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int subsurface_access(const char *path, int mode)
|
int subsurface_access(const char *path, int mode)
|
||||||
|
|
Loading…
Add table
Reference in a new issue