|
From: <sv...@va...> - 2008-03-24 19:05:37
|
Author: bart
Date: 2008-03-24 19:05:36 +0000 (Mon, 24 Mar 2008)
New Revision: 7781
Log:
Changed bitmap implementation such that it works with the original OSet implementation. Restored original OSet implementation.
Modified:
branches/DRDDEV/coregrind/m_oset.c
branches/DRDDEV/exp-drd/drd_bitmap.c
branches/DRDDEV/include/pub_tool_oset.h
Modified: branches/DRDDEV/coregrind/m_oset.c
===================================================================
--- branches/DRDDEV/coregrind/m_oset.c 2008-03-24 12:38:02 UTC (rev 7780)
+++ branches/DRDDEV/coregrind/m_oset.c 2008-03-24 19:05:36 UTC (rev 7781)
@@ -76,10 +76,9 @@
// concurrent uses would screw things up.
#include "pub_core_basics.h"
-#include "pub_core_libcassert.h"
#include "pub_core_libcbase.h"
+#include "pub_core_libcassert.h"
#include "pub_core_libcprint.h"
-#include "pub_core_mallocfree.h"
#include "pub_core_oset.h"
/*--------------------------------------------------------------------*/
@@ -295,7 +294,7 @@
vg_assert(_free);
if (!_cmp) vg_assert(0 == _keyOff); // If no cmp, offset must be zero
- t = VG_(malloc)(sizeof(AvlTree));
+ t = _alloc(sizeof(AvlTree));
t->keyOff = _keyOff;
t->cmp = _cmp;
t->alloc = _alloc;
@@ -345,7 +344,7 @@
vg_assert(sz == t->nElems);
/* Free the AvlTree itself. */
- VG_(free)(t);
+ t->free(t);
}
void VG_(OSetWord_Destroy)(AvlTree* t)
@@ -369,11 +368,6 @@
t->free( node_of_elem(e) );
}
-void* VG_(OSetGen_NodeToElem)(void* node)
-{
- return elem_of_node(node);
-}
-
/*--------------------------------------------------------------------*/
/*--- Insertion ---*/
/*--------------------------------------------------------------------*/
Modified: branches/DRDDEV/exp-drd/drd_bitmap.c
===================================================================
--- branches/DRDDEV/exp-drd/drd_bitmap.c 2008-03-24 12:38:02 UTC (rev 7780)
+++ branches/DRDDEV/exp-drd/drd_bitmap.c 2008-03-24 19:05:36 UTC (rev 7781)
@@ -43,8 +43,6 @@
/* Local function declarations. */
-static void* bm2ref_new(const SizeT size);
-static void bm2ref_del(void* node);
static void bm2_merge(struct bitmap2* const bm2l,
const struct bitmap2* const bm2r);
@@ -72,7 +70,7 @@
bm->cache[i].a1 = 0;
bm->cache[i].bm2 = 0;
}
- bm->oset = VG_(OSetGen_Create)(0, 0, bm2ref_new, bm2ref_del);
+ bm->oset = VG_(OSetGen_Create)(0, 0, VG_(malloc), VG_(free));
s_bitmap_creation_count++;
@@ -81,7 +79,22 @@
void bm_delete(struct bitmap* const bm)
{
+ struct bitmap2* bm2;
+ struct bitmap2ref* bm2ref;
+
tl_assert(bm);
+
+ VG_(OSetGen_ResetIter)(bm->oset);
+ for ( ; (bm2ref = VG_(OSetGen_Next)(bm->oset)) != 0; )
+ {
+ bm2 = bm2ref->bm2;
+ tl_assert(bm2->refcnt >= 1);
+ if (--bm2->refcnt == 0)
+ {
+ VG_(free)(bm2);
+ }
+ }
+
VG_(OSetGen_Destroy)(bm->oset);
VG_(free)(bm);
}
@@ -773,33 +786,6 @@
return s_bitmap2_creation_count;
}
-/** Allocate memory for a tree node, without initializing the tree node. */
-static void* bm2ref_new(const SizeT size)
-{
- void* node = VG_(malloc)(size);
- return node;
-}
-
-/** Deallocate the tree node, decrement the reference count of the second
- * level bitmap and deallocate the second level bitmap memory if the reference
- * count reached zero.
- */
-static void bm2ref_del(void* node)
-{
- struct bitmap2* bm2;
- struct bitmap2ref* bm2ref;
-
- bm2ref = VG_(OSetGen_NodeToElem)(node);
- tl_assert(bm2ref);
- bm2 = bm2ref->bm2;
- tl_assert(bm2->refcnt >= 1);
- if (--bm2->refcnt == 0)
- {
- VG_(free)(bm2);
- }
- VG_(free)(node);
-}
-
/** Allocate and initialize a second level bitmap. */
static struct bitmap2* bm2_new(const UWord a1)
{
Modified: branches/DRDDEV/include/pub_tool_oset.h
===================================================================
--- branches/DRDDEV/include/pub_tool_oset.h 2008-03-24 12:38:02 UTC (rev 7780)
+++ branches/DRDDEV/include/pub_tool_oset.h 2008-03-24 19:05:36 UTC (rev 7781)
@@ -187,7 +187,6 @@
extern void VG_(OSetGen_Destroy) ( OSet* os );
extern void* VG_(OSetGen_AllocNode) ( OSet* os, SizeT elemSize );
extern void VG_(OSetGen_FreeNode) ( OSet* os, void* elem );
-extern void* VG_(OSetGen_NodeToElem)( void* node );
/*--------------------------------------------------------------------*/
/*--- Operations on OSets (Gen) ---*/
|