1
0
mirror of https://github.com/moparisthebest/wget synced 2024-07-03 16:38:41 -04:00

Replace all occurences of free() with xfree()

This commit is contained in:
Darshit Shah 2014-11-27 11:11:34 +05:30
parent 5edc97f3f8
commit 3e609a1192
7 changed files with 37 additions and 32 deletions

View File

@ -1,3 +1,8 @@
2014-11-27 Darshit Shah <darnir@gmail.com>
* cookies.c, gettext.h, init.c, retr.c, url.c, warc.c: Replace usage of
free() with xfree() macro.
2014-11-26 Tim Ruehsen <tim.ruehsen@gmx.de> 2014-11-26 Tim Ruehsen <tim.ruehsen@gmx.de>
* http.c: Select strongest challenge from WWW-Authenticate, * http.c: Select strongest challenge from WWW-Authenticate,

View File

@ -1445,8 +1445,8 @@ test_cookies (void)
printf ("Invalid value %d for '%s' (expected '%s', got '%s')\n", printf ("Invalid value %d for '%s' (expected '%s', got '%s')\n",
j / 2 + 1, data, expected[j + 1], v); j / 2 + 1, data, expected[j + 1], v);
j += 2; j += 2;
free (n); xfree (n);
free (v); xfree (v);
} }
if (expected[j]) if (expected[j])
printf ("Too few parameters for '%s'\n", data); printf ("Too few parameters for '%s'\n", data);

View File

@ -215,7 +215,7 @@ dcpgettext_expr (const char *domain,
translation = dcgettext (domain, msg_ctxt_id, category); translation = dcgettext (domain, msg_ctxt_id, category);
#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
if (msg_ctxt_id != buf) if (msg_ctxt_id != buf)
free (msg_ctxt_id); xfree (msg_ctxt_id);
#endif #endif
if (translation != msg_ctxt_id) if (translation != msg_ctxt_id)
return translation; return translation;
@ -261,7 +261,7 @@ dcnpgettext_expr (const char *domain,
translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category); translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
if (msg_ctxt_id != buf) if (msg_ctxt_id != buf)
free (msg_ctxt_id); xfree (msg_ctxt_id);
#endif #endif
if (!(translation == msg_ctxt_id || translation == msgid_plural)) if (!(translation == msg_ctxt_id || translation == msgid_plural))
return translation; return translation;

View File

@ -486,7 +486,7 @@ home_dir (void)
} }
ret = home ? xstrdup (home) : NULL; ret = home ? xstrdup (home) : NULL;
free (buf); xfree (buf);
return ret; return ret;
} }

View File

@ -441,7 +441,7 @@ fd_read_body (const char *downloaded_filename, int fd, FILE *out, wgint toread,
if (qtywritten) if (qtywritten)
*qtywritten += sum_written; *qtywritten += sum_written;
free (dlbuf); xfree (dlbuf);
return ret; return ret;
} }
@ -790,7 +790,7 @@ retrieve_url (struct url * orig_parsed, const char *origurl, char **file,
goto bail; goto bail;
} }
iri_free(pi); iri_free(pi);
free (proxy); xfree (proxy);
} }
if (u->scheme == SCHEME_HTTP if (u->scheme == SCHEME_HTTP
@ -1099,7 +1099,7 @@ retrieve_from_file (const char *file, bool html, int *count)
cur_url->url->url, &filename, cur_url->url->url, &filename,
&new_file, NULL, &dt, opt.recursive, tmpiri, &new_file, NULL, &dt, opt.recursive, tmpiri,
true); true);
free(proxy); xfree (proxy);
if (parsed_url) if (parsed_url)
url_free (parsed_url); url_free (parsed_url);
@ -1298,7 +1298,7 @@ url_uses_proxy (struct url * u)
return false; return false;
proxy = getproxy (u); proxy = getproxy (u);
ret = proxy != NULL; ret = proxy != NULL;
free(proxy); xfree (proxy);
return ret; return ret;
} }

View File

@ -1643,7 +1643,7 @@ url_file_name (const struct url *u, char *replaced_filename)
logprintf (LOG_NOTQUIET, "New name is %s.\n", temp_fnres.base); logprintf (LOG_NOTQUIET, "New name is %s.\n", temp_fnres.base);
} }
free (fname_len_check); xfree (fname_len_check);
/* The filename has already been 'cleaned' by append_uri_pathel() above. So, /* The filename has already been 'cleaned' by append_uri_pathel() above. So,
* just append it. */ * just append it. */
@ -1656,7 +1656,7 @@ url_file_name (const struct url *u, char *replaced_filename)
/* Make a final check that the path length is acceptable? */ /* Make a final check that the path length is acceptable? */
/* TODO: check fnres.base for path length problem */ /* TODO: check fnres.base for path length problem */
free (temp_fnres.base); xfree (temp_fnres.base);
/* Check the cases in which the unique extensions are not used: /* Check the cases in which the unique extensions are not used:
1) Clobbering is turned off (-nc). 1) Clobbering is turned off (-nc).

View File

@ -469,7 +469,7 @@ warc_sha1_stream_with_payload (FILE *stream, void *res_block, void *res_payload,
or EWOULDBLOCK. */ or EWOULDBLOCK. */
if (ferror (stream)) if (ferror (stream))
{ {
free (buffer); xfree (buffer);
return 1; return 1;
} }
goto process_partial_block; goto process_partial_block;
@ -529,7 +529,7 @@ warc_sha1_stream_with_payload (FILE *stream, void *res_block, void *res_payload,
sha1_finish_ctx (&ctx_block, res_block); sha1_finish_ctx (&ctx_block, res_block);
if (payload_offset >= 0) if (payload_offset >= 0)
sha1_finish_ctx (&ctx_payload, res_payload); sha1_finish_ctx (&ctx_payload, res_payload);
free (buffer); xfree (buffer);
return 0; return 0;
#undef BLOCKSIZE #undef BLOCKSIZE
@ -571,13 +571,13 @@ warc_write_digest_headers (FILE *file, long payload_offset)
digest = warc_base32_sha1_digest (sha1_res_block); digest = warc_base32_sha1_digest (sha1_res_block);
warc_write_header ("WARC-Block-Digest", digest); warc_write_header ("WARC-Block-Digest", digest);
free (digest); xfree (digest);
if (payload_offset >= 0) if (payload_offset >= 0)
{ {
digest = warc_base32_sha1_digest (sha1_res_payload); digest = warc_base32_sha1_digest (sha1_res_payload);
warc_write_header ("WARC-Payload-Digest", digest); warc_write_header ("WARC-Payload-Digest", digest);
free (digest); xfree (digest);
} }
} }
} }
@ -687,8 +687,8 @@ warc_write_warcinfo_record (char *filename)
warc_tmp = warc_tempfile (); warc_tmp = warc_tempfile ();
if (warc_tmp == NULL) if (warc_tmp == NULL)
{ {
free (filename_copy); xfree (filename_copy);
free (filename_basename); xfree (filename_basename);
return false; return false;
} }
@ -714,8 +714,8 @@ warc_write_warcinfo_record (char *filename)
if (! warc_write_ok) if (! warc_write_ok)
logprintf (LOG_NOTQUIET, _("Error writing warcinfo record to WARC file.\n")); logprintf (LOG_NOTQUIET, _("Error writing warcinfo record to WARC file.\n"));
free (filename_copy); xfree (filename_copy);
free (filename_basename); xfree (filename_basename);
fclose (warc_tmp); fclose (warc_tmp);
return warc_write_ok; return warc_write_ok;
} }
@ -755,8 +755,8 @@ warc_start_new_file (bool meta)
if (warc_current_file != NULL) if (warc_current_file != NULL)
fclose (warc_current_file); fclose (warc_current_file);
free (warc_current_warcinfo_uuid_str); xfree (warc_current_warcinfo_uuid_str);
free (warc_current_filename); xfree (warc_current_filename);
warc_current_file_number++; warc_current_file_number++;
@ -917,7 +917,7 @@ warc_process_cdx_line (char *lineptr, int field_num_original_url,
char * checksum_v; char * checksum_v;
base32_decode_alloc (checksum, strlen (checksum), &checksum_v, base32_decode_alloc (checksum, strlen (checksum), &checksum_v,
&checksum_l); &checksum_l);
free (checksum); xfree (checksum);
if (checksum_v != NULL && checksum_l == SHA1_DIGEST_SIZE) if (checksum_v != NULL && checksum_l == SHA1_DIGEST_SIZE)
{ {
@ -928,13 +928,13 @@ warc_process_cdx_line (char *lineptr, int field_num_original_url,
rec->uuid = record_id; rec->uuid = record_id;
memcpy (rec->digest, checksum_v, SHA1_DIGEST_SIZE); memcpy (rec->digest, checksum_v, SHA1_DIGEST_SIZE);
hash_table_put (warc_cdx_dedup_table, rec->digest, rec); hash_table_put (warc_cdx_dedup_table, rec->digest, rec);
free (checksum_v); xfree (checksum_v);
} }
else else
{ {
free (original_url); xfree (original_url);
free (checksum_v); xfree (checksum_v);
free (record_id); xfree (record_id);
} }
} }
else else
@ -1015,7 +1015,7 @@ _("CDX file does not list record ids. (Missing column 'u'.)\n"));
nrecords); nrecords);
} }
free (lineptr); xfree (lineptr);
fclose (f); fclose (f);
return true; return true;
@ -1156,7 +1156,7 @@ warc_close (void)
if (warc_current_file != NULL) if (warc_current_file != NULL)
{ {
warc_write_metadata (); warc_write_metadata ();
free (warc_current_warcinfo_uuid_str); xfree (warc_current_warcinfo_uuid_str);
fclose (warc_current_file); fclose (warc_current_file);
} }
if (warc_current_cdx_file != NULL) if (warc_current_cdx_file != NULL)
@ -1338,7 +1338,7 @@ warc_write_revisit_record (char *url, char *timestamp_str,
warc_write_end_record (); warc_write_end_record ();
fclose (body); fclose (body);
free (block_digest); xfree (block_digest);
return warc_write_ok; return warc_write_ok;
} }
@ -1400,7 +1400,7 @@ warc_write_response_record (char *url, char *timestamp_str,
result = warc_write_revisit_record (url, timestamp_str, result = warc_write_revisit_record (url, timestamp_str,
concurrent_to_uuid, payload_digest, rec_existing->uuid, concurrent_to_uuid, payload_digest, rec_existing->uuid,
ip, body); ip, body);
free (payload_digest); xfree (payload_digest);
return result; return result;
} }
@ -1441,8 +1441,8 @@ warc_write_response_record (char *url, char *timestamp_str,
response_uuid); response_uuid);
} }
free (block_digest); xfree (block_digest);
free (payload_digest); xfree (payload_digest);
return warc_write_ok; return warc_write_ok;
} }