]> granicus.if.org Git - curl/commitdiff
we only allocate the HTTP struct if we need to
authorDaniel Stenberg <daniel@haxx.se>
Thu, 22 Feb 2001 23:41:15 +0000 (23:41 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 22 Feb 2001 23:41:15 +0000 (23:41 +0000)
lib/http.c

index 3184c7f5f14f665ae62d84c122e76f912097e2b7..641373ae276b6ace40dd16973c48c6b2cebcb1f5 100644 (file)
@@ -390,11 +390,15 @@ CURLcode Curl_http(struct connectdata *conn)
   char *host = conn->name;
   long *bytecount = &conn->bytecount;
 
-  http = (struct HTTP *)malloc(sizeof(struct HTTP));
-  if(!http)
-    return CURLE_OUT_OF_MEMORY;
-  memset(http, 0, sizeof(struct HTTP));
-  conn->proto.http = http;
+  if(!conn->proto.http) {
+    /* Only allocate this struct if we don't already have it! */
+
+    http = (struct HTTP *)malloc(sizeof(struct HTTP));
+    if(!http)
+      return CURLE_OUT_OF_MEMORY;
+    memset(http, 0, sizeof(struct HTTP));
+    conn->proto.http = http;
+  }
 
   if ( (conn->protocol&(PROT_HTTP|PROT_FTP)) &&
        data->bits.upload) {