From 505e0b7b02818b70cca8f1e911348a0da49ebdd0 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Thu, 24 Jan 2002 19:33:09 +0000 Subject: [PATCH] Fix memory leak for MARC record management. --- zoom/zoom-c.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/zoom/zoom-c.c b/zoom/zoom-c.c index ddca641..96321be 100644 --- a/zoom/zoom-c.c +++ b/zoom/zoom-c.c @@ -1,5 +1,5 @@ /* - * $Id: zoom-c.c,v 1.21 2002-01-21 21:50:32 adam Exp $ + * $Id: zoom-c.c,v 1.22 2002-01-24 19:33:09 adam Exp $ * * ZOOM layer for C, connections, result sets, queries. */ @@ -416,6 +416,11 @@ void ZOOM_resultset_destroy(ZOOM_resultset r) yaz_log (LOG_DEBUG, "destroy r = %p count=%d", r, r->refcount); if (r->refcount == 0) { + ZOOM_record_cache rc; + + for (rc = r->record_cache; rc; rc = rc->next) + if (rc->rec.wrbuf_marc) + wrbuf_free (rc->rec.wrbuf_marc, 1); if (r->connection) { /* remove ourselves from the resultsets in connection */ @@ -915,6 +920,7 @@ void *ZOOM_record_get (ZOOM_record rec, const char *type, size_t *len) default: if (!rec->wrbuf_marc) rec->wrbuf_marc = wrbuf_alloc(); + wrbuf_rewind (rec->wrbuf_marc); if (marc_display_wrbuf (r->u.octet_aligned->buf, rec->wrbuf_marc, 0, r->u.octet_aligned->len) > 0) @@ -982,7 +988,6 @@ static void record_cache_add (ZOOM_resultset r, return; } } - } rc = odr_malloc (r->odr, sizeof(*rc)); rc->rec.npr = npr; -- 1.7.10.4