diff options
author | Max <mparisi@stevens.edu> | 2020-09-15 18:01:21 -0400 |
---|---|---|
committer | Max <mparisi@stevens.edu> | 2020-09-15 18:01:21 -0400 |
commit | 4febf81f59b047482fa0575db45e3b80c18c55a3 (patch) | |
tree | aaef9bf8df52fb56009e770209e93c3ed60c8030 | |
parent | 67fd727a3c293215c644bb690bad1db0df67046f (diff) |
hashtable.c matches, but needs cleanup
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | include/darray.h | 1 | ||||
-rw-r--r-- | include/hashtable.h | 2 | ||||
-rw-r--r-- | src/hashtable.c | 29 |
4 files changed, 14 insertions, 20 deletions
@@ -18,4 +18,4 @@ *.exe
build
.idea
-.dump
+*.dump
diff --git a/include/darray.h b/include/darray.h index 09c9db8..a5fff87 100644 --- a/include/darray.h +++ b/include/darray.h @@ -17,6 +17,7 @@ typedef struct unkStruct2 { void *ArrayNth(unkStruct2 *p1, s32 p2);
+void *ArrayMapBackwards2(unkStruct2 *p1, s32 p2, s32 p3);
#ifdef __cplusplus
}
diff --git a/include/hashtable.h b/include/hashtable.h index f2a9f22..93d27cd 100644 --- a/include/hashtable.h +++ b/include/hashtable.h @@ -27,7 +27,7 @@ void TableEnter(unkStruct *p1, void *p2); BOOL TableRemove(unkStruct *p1, void *p2);
void *TableLookup(unkStruct *p1, void *p2);
void TableMapSafe(unkStruct *p1, s32 p2, s32 p3);
-void TableMapSafe2(unkStruct *p1, s32 p2, s32 p3);
+void *TableMapSafe2(unkStruct *p1, s32 p2, s32 p3);
#ifdef __cplusplus
}
diff --git a/src/hashtable.c b/src/hashtable.c index 9d452e6..4c60efd 100644 --- a/src/hashtable.c +++ b/src/hashtable.c @@ -1,15 +1,3 @@ -#if 0
-==TableNew 8035aeb4 8033680c 1c
-==TableNew2 8035aed0 80336828 a4
-==TableFree 8035af74 803368cc 7c
-==TableCount 8035aff0 80336948 88
-==TableEnter 8035b078 803369d0 a8
-==TableRemove 8035b120 80336a78 a4
-==TableLookup 8035b1c4 80336b1c a0
-==TableMapSafe 8035b264 80336bbc 6c
-==TableMapSafe2 8035b2d0 80336c28 7c
-#endif
-
#include "types.h"
#include "hashtable.h"
@@ -43,12 +31,14 @@ void TableFree(unkStruct *p1) }
}
+// r29: totalSize
+// r30: i
s32 TableCount(unkStruct *p1)
{
+ s32 i, totalSize = 0;
if (!p1)
return 0;
- s32 totalSize = 0;
- for (s32 i = 0; i < p1->unk4; i++) {
+ for (i = 0; i < p1->unk4; i++) {
totalSize += ArrayLength(p1->unk0[i]);
}
return totalSize;
@@ -104,11 +94,14 @@ void TableMapSafe(unkStruct *p1, s32 p2, s32 p3) }
}
-void TableMapSafe2(unkStruct *p1, s32 p2, s32 p3)
+void *TableMapSafe2(unkStruct *p1, s32 p2, s32 p3)
{
- for (s32 i = 0; i < p1->unk4; i++) {
- if (ArrayMapBackwards2(p1->unk0[i], p2, p3)) {
- break;
+ s32 i;
+ void *result;
+ for (i = 0; i < p1->unk4; i++) {
+ if ((result = ArrayMapBackwards2(p1->unk0[i], p2, p3)) != NULL) {
+ return result;
}
}
+ return NULL;
}
|