From 0285c2984fc1913d583432716d6fff4f9f291994 Mon Sep 17 00:00:00 2001 From: James Bursa Date: Fri, 25 Apr 2003 08:03:15 +0000 Subject: [project @ 2003-04-25 08:03:15 by bursa] Various memory fixes. svn path=/import/netsurf/; revision=128 --- content/fetch.c | 29 +++++++++++++++++------------ content/fetchcache.c | 4 ++-- 2 files changed, 19 insertions(+), 14 deletions(-) (limited to 'content') diff --git a/content/fetch.c b/content/fetch.c index 93a0c124d..bbf6b2916 100644 --- a/content/fetch.c +++ b/content/fetch.c @@ -1,5 +1,5 @@ /** - * $Id: fetch.c,v 1.6 2003/04/17 21:35:02 bursa Exp $ + * $Id: fetch.c,v 1.7 2003/04/25 08:03:15 bursa Exp $ * * This module handles fetching of data from any url. * @@ -114,7 +114,9 @@ struct fetch * fetch_start(char *url, char *referer, fetch->referer = xstrdup(referer); fetch->p = p; fetch->headers = 0; - fetch->host = xstrdup(uri->server); + fetch->host = 0; + if (uri->server != 0) + fetch->host = xstrdup(uri->server); fetch->queue = 0; fetch->prev = 0; fetch->next = 0; @@ -122,16 +124,19 @@ struct fetch * fetch_start(char *url, char *referer, xmlFreeURI(uri); /* look for a fetch from the same host */ - for (host_fetch = fetch_list; - host_fetch != 0 && strcasecmp(host_fetch->host, fetch->host) != 0; - host_fetch = host_fetch->next) - ; - if (host_fetch != 0) { - /* fetch from this host in progress: queue the new fetch */ - LOG(("queueing")); - fetch->queue = host_fetch->queue; - host_fetch->queue = fetch; - return fetch; + if (fetch->host != 0) { + for (host_fetch = fetch_list; + host_fetch != 0 && (host_fetch->host == 0 || + strcasecmp(host_fetch->host, fetch->host) != 0); + host_fetch = host_fetch->next) + ; + if (host_fetch != 0) { + /* fetch from this host in progress: queue the new fetch */ + LOG(("queueing")); + fetch->queue = host_fetch->queue; + host_fetch->queue = fetch; + return fetch; + } } fetch->next = fetch_list; diff --git a/content/fetchcache.c b/content/fetchcache.c index 34105c71d..600fd13fd 100644 --- a/content/fetchcache.c +++ b/content/fetchcache.c @@ -1,5 +1,5 @@ /** - * $Id: fetchcache.c,v 1.8 2003/04/17 21:35:02 bursa Exp $ + * $Id: fetchcache.c,v 1.9 2003/04/25 08:03:15 bursa Exp $ */ #include @@ -115,7 +115,7 @@ void fetchcache_callback(fetch_msg msg, void *p, char *data, unsigned long size) switch (msg) { case FETCH_TYPE: - mime_type = strdup(data); + mime_type = xstrdup(data); if ((semic = strchr(mime_type, ';')) != 0) *semic = 0; /* remove "; charset=..." */ type = content_lookup(mime_type); -- cgit v1.2.3