projects
/
mmh
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix unreproducible build
[mmh]
/
uip
/
mhfree.c
diff --git
a/uip/mhfree.c
b/uip/mhfree.c
index
6918e0e
..
5378c35
100644
(file)
--- a/
uip/mhfree.c
+++ b/
uip/mhfree.c
@@
-8,9
+8,11
@@
*/
#include <h/mh.h>
*/
#include <h/mh.h>
+#include <h/utils.h>
#include <errno.h>
#include <h/mime.h>
#include <h/mhparse.h>
#include <errno.h>
#include <h/mime.h>
#include <h/mhparse.h>
+#include <unistd.h>
/* The list of top-level contents to display */
CT *cts = NULL;
/* The list of top-level contents to display */
CT *cts = NULL;
@@
-22,7
+24,7
@@
void free_content(CT);
void free_header(CT);
void free_ctinfo(CT);
void free_encoding(CT, int);
void free_header(CT);
void free_ctinfo(CT);
void free_encoding(CT, int);
-void freects_done(int);
+void freects_done();
/*
** static prototypes
/*
** static prototypes
@@
-30,7
+32,6
@@
void freects_done(int);
static void free_text(CT);
static void free_multi(CT);
static void free_partial(CT);
static void free_text(CT);
static void free_multi(CT);
static void free_partial(CT);
-static void free_external(CT);
/*
/*
@@
-49,13
+50,13
@@
free_content(CT ct)
free_header(ct);
if (ct->c_partno)
free_header(ct);
if (ct->c_partno)
- free(ct->c_partno);
+ mh_free0(&(ct->c_partno));
if (ct->c_vrsn)
if (ct->c_vrsn)
- free(ct->c_vrsn);
+ mh_free0(&(ct->c_vrsn));
if (ct->c_ctline)
if (ct->c_ctline)
- free(ct->c_ctline);
+ mh_free0(&(ct->c_ctline));
free_ctinfo(ct);
free_ctinfo(ct);
@@
-64,61
+65,55
@@
free_content(CT ct)
** parts which need to be freed.
*/
switch (ct->c_type) {
** parts which need to be freed.
*/
switch (ct->c_type) {
- case CT_MULTIPART:
- free_multi(ct);
- break;
-
- case CT_MESSAGE:
- switch (ct->c_subtype) {
- case MESSAGE_PARTIAL:
- free_partial(ct);
- break;
-
- case MESSAGE_EXTERNAL:
- free_external(ct);
- break;
- }
- break;
-
- case CT_TEXT:
- free_text(ct);
- break;
+ case CT_MULTIPART:
+ free_multi(ct);
+ break;
+
+ case CT_MESSAGE:
+ if (ct->c_subtype == MESSAGE_PARTIAL) {
+ free_partial(ct);
+ }
+ break;
+
+ case CT_TEXT:
+ free_text(ct);
+ break;
}
}
+ if (ct->c_charset)
+ mh_free0(&(ct->c_charset));
if (ct->c_showproc)
if (ct->c_showproc)
- free(ct->c_showproc);
- if (ct->c_termproc)
- free(ct->c_termproc);
+ mh_free0(&(ct->c_showproc));
if (ct->c_storeproc)
if (ct->c_storeproc)
- free(ct->c_storeproc);
+ mh_free0(&(ct->c_storeproc));
if (ct->c_celine)
if (ct->c_celine)
- free(ct->c_celine);
+ mh_free0(&(ct->c_celine));
/* free structures for content encodings */
free_encoding(ct, 1);
if (ct->c_id)
/* free structures for content encodings */
free_encoding(ct, 1);
if (ct->c_id)
- free(ct->c_id);
+ mh_free0(&(ct->c_id));
if (ct->c_descr)
if (ct->c_descr)
- free(ct->c_descr);
+ mh_free0(&(ct->c_descr));
if (ct->c_dispo)
if (ct->c_dispo)
- free(ct->c_dispo);
+ mh_free0(&(ct->c_dispo));
if (ct->c_file) {
if (ct->c_unlink)
unlink(ct->c_file);
if (ct->c_file) {
if (ct->c_unlink)
unlink(ct->c_file);
- free(ct->c_file);
+ mh_free0(&(ct->c_file));
}
if (ct->c_fp)
fclose(ct->c_fp);
if (ct->c_storage)
}
if (ct->c_fp)
fclose(ct->c_fp);
if (ct->c_storage)
- free(ct->c_storage);
+ mh_free0(&(ct->c_storage));
if (ct->c_folder)
if (ct->c_folder)
- free(ct->c_folder);
+ mh_free0(&(ct->c_folder));
- free(ct);
+ mh_free0(&ct);
}
}
@@
-136,9
+131,9
@@
free_header(CT ct)
while (hp1) {
hp2 = hp1->next;
while (hp1) {
hp2 = hp1->next;
- free(hp1->name);
- free(hp1->value);
- free(hp1);
+ mh_free0(&(hp1->name));
+ mh_free0(&(hp1->value));
+ mh_free0(&hp1);
hp1 = hp2;
}
hp1 = hp2;
}
@@
-156,24
+151,19
@@
free_ctinfo(CT ct)
ci = &ct->c_ctinfo;
if (ci->ci_type) {
ci = &ct->c_ctinfo;
if (ci->ci_type) {
- free(ci->ci_type);
- ci->ci_type = NULL;
+ mh_free0(&(ci->ci_type));
}
if (ci->ci_subtype) {
}
if (ci->ci_subtype) {
- free(ci->ci_subtype);
- ci->ci_subtype = NULL;
+ mh_free0(&(ci->ci_subtype));
}
for (ap = ci->ci_attrs; *ap; ap++) {
}
for (ap = ci->ci_attrs; *ap; ap++) {
- free(*ap);
- *ap = NULL;
+ mh_free0(ap);
}
if (ci->ci_comment) {
}
if (ci->ci_comment) {
- free(ci->ci_comment);
- ci->ci_comment = NULL;
+ mh_free0(&(ci->ci_comment));
}
if (ci->ci_magic) {
}
if (ci->ci_magic) {
- free(ci->ci_magic);
- ci->ci_magic = NULL;
+ mh_free0(&(ci->ci_magic));
}
}
}
}
@@
-186,8
+176,7
@@
free_text(CT ct)
if (!(t = (struct text *) ct->c_ctparams))
return;
if (!(t = (struct text *) ct->c_ctparams))
return;
- free((char *) t);
- ct->c_ctparams = NULL;
+ mh_free0(&t);
}
}
@@
-201,19
+190,17
@@
free_multi(CT ct)
return;
if (m->mp_start)
return;
if (m->mp_start)
- free(m->mp_start);
+ mh_free0(&(m->mp_start));
if (m->mp_stop)
if (m->mp_stop)
- free(m->mp_stop);
+ mh_free0(&(m->mp_stop));
for (part = m->mp_parts; part; part = next) {
next = part->mp_next;
free_content(part->mp_part);
for (part = m->mp_parts; part; part = next) {
next = part->mp_next;
free_content(part->mp_part);
- free((char *) part);
+ mh_free0(&part);
}
}
- m->mp_parts = NULL;
- free((char *) m);
- ct->c_ctparams = NULL;
+ mh_free0(&m);
}
}
@@
-226,27
+213,9
@@
free_partial(CT ct)
return;
if (p->pm_partid)
return;
if (p->pm_partid)
- free(p->pm_partid);
+ mh_free0(&(p->pm_partid));
- free((char *) p);
- ct->c_ctparams = NULL;
-}
-
-
-static void
-free_external(CT ct)
-{
- struct exbody *e;
-
- if (!(e = (struct exbody *) ct->c_ctparams))
- return;
-
- free_content(e->eb_content);
- if (e->eb_body)
- free(e->eb_body);
-
- free((char *) e);
- ct->c_ctparams = NULL;
+ mh_free0(&p);
}
}
@@
-271,13
+240,11
@@
free_encoding(CT ct, int toplevel)
if (ce->ce_file) {
if (ce->ce_unlink)
unlink(ce->ce_file);
if (ce->ce_file) {
if (ce->ce_unlink)
unlink(ce->ce_file);
- free(ce->ce_file);
- ce->ce_file = NULL;
+ mh_free0(&(ce->ce_file));
}
if (toplevel) {
}
if (toplevel) {
- free((char *) ce);
- ct->c_cefile = NULL;
+ mh_free0(&ce);
} else {
ct->c_ceopenfnx = NULL;
}
} else {
ct->c_ceopenfnx = NULL;
}
@@
-285,13
+252,13
@@
free_encoding(CT ct, int toplevel)
void
void
-freects_done(int status)
+freects_done()
{
CT *ctp;
{
CT *ctp;
- if ((ctp = cts))
- for (; *ctp; ctp++)
+ if ((ctp = cts)) {
+ for (; *ctp; ctp++){
free_content(*ctp);
free_content(*ctp);
-
- exit(status);
+ }
+ }
}
}