cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: [PATCH] Include local IP address in the connection cache hash

From: Kamil Dudka <kdudka_at_redhat.com>
Date: Mon, 11 Mar 2013 22:02:28 +0100

On Monday, March 11, 2013 21:39:49 Linus Nielsen Feltzing wrote:
> +/* Combine hostname and local IP address to create a keystring for hashing */
> +static char *create_hash_key(struct connectdata *conn)
> +{
> + size_t iplen = strlen(conn->local_ip);
> + size_t hostlen = strlen(conn->host.name);
> + char *key = malloc(hostlen + iplen + 1);
> +
> + if(!key)
> + return NULL;
> +
> + strcpy(key, conn->local_ip);
> + strcpy(key + iplen, conn->host.name);
> + return key;
> +}

Please consider replacing the open-coded string concatenation above by:

    return aprintf("%s%s", conn->local_ip, conn->host.name);

Kamil
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2013-03-11