misc: remove unnecessary null pointer checks

Fixes: https://github.com/libuv/libuv/issues/595
PR-URL: https://github.com/libuv/libuv/pull/604
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
This commit is contained in:
Ian Kronquist 2015-11-02 14:49:22 -08:00 committed by Saúl Ibarra Corretgé
parent f41b7386de
commit 81072b98f5
4 changed files with 10 additions and 16 deletions

View File

@ -39,10 +39,8 @@ int uv_dlopen(const char* filename, uv_lib_t* lib) {
void uv_dlclose(uv_lib_t* lib) {
if (lib->errmsg) {
uv__free(lib->errmsg);
lib->errmsg = NULL;
}
uv__free(lib->errmsg);
lib->errmsg = NULL;
if (lib->handle) {
/* Ignore errors. No good way to signal them without leaking memory. */
@ -67,8 +65,7 @@ const char* uv_dlerror(const uv_lib_t* lib) {
static int uv__dlerror(uv_lib_t* lib) {
const char* errmsg;
if (lib->errmsg)
uv__free(lib->errmsg);
uv__free(lib->errmsg);
errmsg = dlerror();

View File

@ -176,7 +176,7 @@ char** uv_setup_args(int argc, char** argv) {
int uv_set_process_title(const char* title) {
int oid[4];
if (process_title) uv__free(process_title);
uv__free(process_title);
process_title = uv__strdup(title);
oid[0] = CTL_KERN;

View File

@ -161,7 +161,7 @@ char** uv_setup_args(int argc, char** argv) {
int uv_set_process_title(const char* title) {
if (process_title) uv__free(process_title);
uv__free(process_title);
process_title = uv__strdup(title);
setproctitle(title);
return 0;

View File

@ -109,10 +109,8 @@ static void uv__getaddrinfo_done(struct uv__work* w, int status) {
req = container_of(w, uv_getaddrinfo_t, work_req);
/* release input parameter memory */
if (req->alloc != NULL) {
uv__free(req->alloc);
req->alloc = NULL;
}
uv__free(req->alloc);
req->alloc = NULL;
if (status == UV_ECANCELED) {
assert(req->retcode == 0);
@ -219,9 +217,7 @@ void uv_freeaddrinfo(struct addrinfo* ai) {
char* alloc_ptr = (char*)ai;
/* release copied result memory */
if (alloc_ptr != NULL) {
uv__free(alloc_ptr);
}
uv__free(alloc_ptr);
}
@ -354,8 +350,9 @@ int uv_getaddrinfo(uv_loop_t* loop,
}
error:
if (req != NULL && req->alloc != NULL) {
if (req != NULL) {
uv__free(req->alloc);
req->alloc = NULL;
}
return uv_translate_sys_error(err);
}