From 17bcee91fd35f05769e50c4707a341c39c32a9c9 Mon Sep 17 00:00:00 2001 From: chris mikkelson Date: Sat, 13 Mar 2010 00:02:36 -0600 Subject: [PATCH] Allocate ssm_nmsg_state structure only once per connection structure. The calling smtpsink recycles the structures, and can recycle private data along with it. --- ssm_nmsg.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ssm_nmsg.c b/ssm_nmsg.c index 2b35d45..9ad51bf 100644 --- a/ssm_nmsg.c +++ b/ssm_nmsg.c @@ -82,10 +82,12 @@ struct smtpsink_module ss_module; static int ssm_nmsg_connect(struct conn *c) { - struct ssm_nmsg_state *nms = malloc(sizeof(struct ssm_nmsg_state)); + struct ssm_nmsg_state *nms = ssm_getpriv(&ss_module, c); char ip[80]; const uint8_t *addr = (const uint8_t *)ip; + if (!nms) nms = malloc(sizeof(struct ssm_nmsg_state)); + if (nms) { nms->msg = nmsg_message_init(nmsg_emailmod); nms->nurl = 0; -- 2.50.1