Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
htop
Commits
36848494
Commit
36848494
authored
Nov 12, 2006
by
Hisham Muhammad
Browse files
Add debugging sanity checks.
parent
c90a4451
Changes
4
Hide whitespace changes
Inline
Side-by-side
Hashtable.c
View file @
36848494
...
...
@@ -46,6 +46,19 @@ bool Hashtable_isConsistent(Hashtable* this) {
return
items
==
this
->
items
;
}
int
Hashtable_count
(
Hashtable
*
this
)
{
int
items
=
0
;
for
(
int
i
=
0
;
i
<
this
->
size
;
i
++
)
{
HashtableItem
*
bucket
=
this
->
buckets
[
i
];
while
(
bucket
)
{
items
++
;
bucket
=
bucket
->
next
;
}
}
assert
(
items
==
this
->
items
);
return
items
;
}
#endif
HashtableItem
*
HashtableItem_new
(
int
key
,
void
*
value
)
{
...
...
Hashtable.h
View file @
36848494
...
...
@@ -12,6 +12,7 @@ in the source distribution for its full text.
#include <stdlib.h>
#include <stdbool.h>
#include <assert.h>
#include "debug.h"
...
...
@@ -32,6 +33,14 @@ struct Hashtable_ {
bool
owner
;
};
#ifdef DEBUG
bool
Hashtable_isConsistent
(
Hashtable
*
this
);
int
Hashtable_count
(
Hashtable
*
this
);
#endif
HashtableItem
*
HashtableItem_new
(
int
key
,
void
*
value
);
Hashtable
*
Hashtable_new
(
int
size
,
bool
owner
);
...
...
@@ -43,7 +52,7 @@ inline int Hashtable_size(Hashtable* this);
void
Hashtable_put
(
Hashtable
*
this
,
int
key
,
void
*
value
);
void
*
Hashtable_remove
(
Hashtable
*
this
,
int
key
);
//#include <stdio.h>
inline
void
*
Hashtable_get
(
Hashtable
*
this
,
int
key
);
void
Hashtable_foreach
(
Hashtable
*
this
,
Hashtable_PairFunction
f
,
void
*
userData
);
...
...
Vector.c
View file @
36848494
...
...
@@ -74,6 +74,16 @@ static inline bool Vector_isConsistent(Vector* this) {
}
}
int
Vector_count
(
Vector
*
this
)
{
int
items
=
0
;
for
(
int
i
=
0
;
i
<
this
->
items
;
i
++
)
{
if
(
this
->
array
[
i
])
items
++
;
}
assert
(
items
==
this
->
items
);
return
items
;
}
#endif
void
Vector_prune
(
Vector
*
this
)
{
...
...
@@ -223,8 +233,9 @@ void Vector_add(Vector* this, void* data_) {
assert
(
data_
&&
((
Object
*
)
data_
)
->
class
==
this
->
vectorType
);
Object
*
data
=
data_
;
assert
(
Vector_isConsistent
(
this
));
int
i
=
this
->
items
;
Vector_set
(
this
,
this
->
items
,
data
);
assert
(
this
->
items
==
i
+
1
);
(
void
)(
i
);
assert
(
Vector_isConsistent
(
this
));
}
...
...
Vector.h
View file @
36848494
...
...
@@ -41,6 +41,8 @@ void Vector_delete(Vector* this);
#ifdef DEBUG
int
Vector_count
(
Vector
*
this
);
#endif
void
Vector_prune
(
Vector
*
this
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment