summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2006-06-27 13:09:57 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2006-06-27 13:09:57 +0000
commit362f3f52c6b7627408e2251688e8f66bba0182dd (patch)
tree3591106b5bdb275e3d0b931729fb973e8ca44783
parentdec5a27234c9ff2b1f4950438a39cb094db01ff6 (diff)
downloadmailutils-362f3f52c6b7627408e2251688e8f66bba0182dd.tar.gz
mailutils-362f3f52c6b7627408e2251688e8f66bba0182dd.tar.bz2
(struct mu_message.needs_destroy): New member
(mu_scm_message_mark): Raise needs_destroy if the message has null owner. (mu_scm_message_free): Do not attempt to reference msg, unless its needs_destroy is set.
-rw-r--r--libmu_scm/mu_message.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/libmu_scm/mu_message.c b/libmu_scm/mu_message.c
index 7c3f98a8d..79ff46331 100644
--- a/libmu_scm/mu_message.c
+++ b/libmu_scm/mu_message.c
@@ -23,7 +23,9 @@ long message_tag;
struct mu_message
{
mu_message_t msg; /* Message itself */
- SCM mbox; /* Mailbox it belongs to */
+ SCM mbox; /* Mailbox it belongs to */
+ int needs_destroy; /* Set during mark phase if the message needs
+ explicit destroying */
};
/* SMOB functions: */
@@ -32,6 +34,8 @@ static SCM
mu_scm_message_mark (SCM message_smob)
{
struct mu_message *mum = (struct mu_message *) SCM_CDR (message_smob);
+ if (mu_message_get_owner (mum->msg) == NULL)
+ mum->needs_destroy = 1;
return mum->mbox;
}
@@ -39,7 +43,7 @@ static scm_sizet
mu_scm_message_free (SCM message_smob)
{
struct mu_message *mum = (struct mu_message *) SCM_CDR (message_smob);
- if (mu_message_get_owner (mum->msg) == NULL)
+ if (mum->needs_destroy)
mu_message_destroy (&mum->msg, NULL);
free (mum);
return sizeof (struct mu_message);
@@ -128,6 +132,7 @@ mu_scm_message_create (SCM owner, mu_message_t msg)
mum = scm_gc_malloc (sizeof (struct mu_message), "message");
mum->msg = msg;
mum->mbox = owner;
+ mum->needs_destroy = 0;
SCM_RETURN_NEWSMOB (message_tag, mum);
}

Return to:

Send suggestions and report system problems to the System administrator.