X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=util%2Fnmem.c;h=5f55cee7acd9d003dfa3c46931c10434673a5cf9;hp=72fc0a888aaacd12b26fc8e72362f600fab87f2a;hb=a49837cbe6fcbeeb9ce857b0eeb942619ba80b5e;hpb=576bbdac86159c56e0f609177a355e59e7cfc3a8 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;