TLV to memPools

From: Andres Kroonmaa <andre@dont-contact.us>
Date: Mon, 8 Oct 2001 16:49:51 +0200

 Does it make sense to convert TLV stuff to memPools?
 Specifically, TLV->value is currently xmalloced, but
 as its size is known at both alloc and free time, we
 can convert this to memAllocBuf/memFreeBuf.

 Immediate benefits are almost none, only just reduce
 number of xmallocs past memPools, and account this
 mem traffic to String Pools.

 something like this (untested):
--- store_swapmeta.c 2001/04/18 18:35:33 1.6.24.1
+++ store_swapmeta.c 2001/10/08 14:55:08
@@ -38,10 +38,12 @@
 static tlv **
 storeSwapTLVAdd(int type, const void *ptr, size_t len, tlv ** tail)
 {
+ int unused;
     tlv *t = memAllocate(MEM_TLV);
     t->type = (char) type;
     t->length = (int) len;
- t->value = xmalloc(len);
+ t->value = memAllocBuf(len, &unused);
+// t->value = xmalloc(len);
     xmemcpy(t->value, ptr, len);
     *tail = t;
     return &t->next; /* return new tail pointer */
@@ -53,7 +55,8 @@
     tlv *t;
     while ((t = n) != NULL) {
  n = t->next;
- xfree(t->value);
+ memFreeBuf(t->length, t->value);
+// xfree(t->value);
        memFree(t, MEM_TLV);
     }
 }

------------------------------------
 Andres Kroonmaa <andre@online.ee>
 CTO, Microlink Online
 Tel: 6501 731, Fax: 6501 725
 Pärnu mnt. 158, Tallinn,
 11317 Estonia
Received on Mon Oct 08 2001 - 08:57:00 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:14:26 MST