From a49837cbe6fcbeeb9ce857b0eeb942619ba80b5e Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 19 Oct 1998 15:24:20 +0000 Subject: [PATCH] New nmem utility, nmem_transfer, that transfer blocks from one NMEM to another. --- include/nmem.h | 7 ++++++- util/nmem.c | 21 +++++++++++++++++++-- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/include/nmem.h b/include/nmem.h index 09b1149..1b7327f 100644 --- a/include/nmem.h +++ b/include/nmem.h @@ -24,7 +24,11 @@ * OF THIS SOFTWARE. * * $Log: nmem.h,v $ - * Revision 1.9 1998-10-13 16:00:17 adam + * Revision 1.10 1998-10-19 15:24:20 adam + * New nmem utility, nmem_transfer, that transfer blocks from one + * NMEM to another. + * + * Revision 1.9 1998/10/13 16:00:17 adam * Implemented nmem_critical_{enter,leave}. * * Revision 1.8 1998/07/20 12:35:59 adam @@ -71,6 +75,7 @@ typedef struct nmem_control *NMEM; YAZ_EXPORT void nmem_reset(NMEM n); YAZ_EXPORT int nmem_total(NMEM n); YAZ_EXPORT char *nmem_strdup (NMEM mem, const char *src); +YAZ_EXPORT void nmem_transfer (NMEM dst, NMEM src); YAZ_EXPORT void nmem_critical_enter (void); YAZ_EXPORT void nmem_critical_leave (void); diff --git a/util/nmem.c b/util/nmem.c index 72fc0a8..5f55cee 100644 --- a/util/nmem.c +++ b/util/nmem.c @@ -4,7 +4,11 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: nmem.c,v $ - * Revision 1.12 1998-10-13 16:00:18 adam + * Revision 1.13 1998-10-19 15:24:21 adam + * New nmem utility, nmem_transfer, that transfer blocks from one + * NMEM to another. + * + * Revision 1.12 1998/10/13 16:00:18 adam * Implemented nmem_critical_{enter,leave}. * * Revision 1.11 1998/08/21 14:13:36 adam @@ -150,8 +154,8 @@ void nmem_reset(NMEM n) n->blocks = n->blocks->next; free_block(t); } - NMEM_LEAVE; n->total = 0; + NMEM_LEAVE; } #if NMEM_DEBUG @@ -237,6 +241,19 @@ void nmem_destroy(NMEM n) #endif } +void nmem_transfer (NMEM dst, NMEM src) +{ + nmem_block *t; + while ((t=src->blocks)) + { + src->blocks = t->next; + t->next = dst->blocks; + dst->blocks = t; + } + dst->total += src->total; + src->total = 0; +} + void nmem_critical_enter (void) { NMEM_ENTER; -- 1.7.10.4