From: Daniel Stenberg Date: Sat, 29 Jan 2022 22:06:13 +0000 (+0100) Subject: conncache: make conncache_add_bundle return the pointer X-Git-Tag: curl-7_82_0~164 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=79cca04da8ee0f2e7abe508db1cecff5e39d2299;p=thirdparty%2Fcurl.git conncache: make conncache_add_bundle return the pointer Simplifies the logic a little and avoids a ternary operator. Ref: #8346 Closes #8349 --- diff --git a/lib/conncache.c b/lib/conncache.c index 493758dc58..cd5756ae40 100644 --- a/lib/conncache.c +++ b/lib/conncache.c @@ -193,13 +193,11 @@ Curl_conncache_find_bundle(struct Curl_easy *data, return bundle; } -static bool conncache_add_bundle(struct conncache *connc, - char *key, - struct connectbundle *bundle) +static void *conncache_add_bundle(struct conncache *connc, + char *key, + struct connectbundle *bundle) { - void *p = Curl_hash_add(&connc->hash, key, strlen(key), bundle); - - return p?TRUE:FALSE; + return Curl_hash_add(&connc->hash, key, strlen(key), bundle); } static void conncache_remove_bundle(struct conncache *connc, @@ -238,7 +236,6 @@ CURLcode Curl_conncache_add_conn(struct Curl_easy *data) bundle = Curl_conncache_find_bundle(data, conn, data->state.conn_cache, NULL); if(!bundle) { - int rc; char key[HASHKEY_SIZE]; result = bundle_create(&bundle); @@ -247,9 +244,8 @@ CURLcode Curl_conncache_add_conn(struct Curl_easy *data) } hashkey(conn, key, sizeof(key), NULL); - rc = conncache_add_bundle(data->state.conn_cache, key, bundle); - if(!rc) { + if(!conncache_add_bundle(data->state.conn_cache, key, bundle)) { bundle_destroy(bundle); result = CURLE_OUT_OF_MEMORY; goto unlock;