You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by nw...@apache.org on 2014/11/11 21:01:41 UTC

[4/5] lucy-clownfish git commit: Use int32_t for HashIterator ticks

Use int32_t for HashIterator ticks


Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/b3132fb1
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/b3132fb1
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/b3132fb1

Branch: refs/heads/master
Commit: b3132fb16145d764107b9c12e3394b271cb2921e
Parents: 264a3f3
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Tue Nov 11 20:51:22 2014 +0100
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Tue Nov 11 20:54:28 2014 +0100

----------------------------------------------------------------------
 runtime/core/Clownfish/Hash.c           | 5 +++++
 runtime/core/Clownfish/HashIterator.cfh | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/b3132fb1/runtime/core/Clownfish/Hash.c
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/Hash.c b/runtime/core/Clownfish/Hash.c
index 403ee1e..ac04562 100644
--- a/runtime/core/Clownfish/Hash.c
+++ b/runtime/core/Clownfish/Hash.c
@@ -320,6 +320,11 @@ Hash_Get_Size_IMP(Hash *self) {
 
 static CFISH_INLINE HashEntry*
 SI_rebuild_hash(Hash *self) {
+    // HashIterator ticks are int32_t.
+    if (self->capacity > INT32_MAX / 2) {
+        THROW(ERR, "Hash grew too large");
+    }
+
     HashEntry *old_entries = (HashEntry*)self->entries;
     HashEntry *entry       = old_entries;
     HashEntry *limit       = old_entries + self->capacity;

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/b3132fb1/runtime/core/Clownfish/HashIterator.cfh
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/HashIterator.cfh b/runtime/core/Clownfish/HashIterator.cfh
index a636504..3e9e1f1 100644
--- a/runtime/core/Clownfish/HashIterator.cfh
+++ b/runtime/core/Clownfish/HashIterator.cfh
@@ -22,7 +22,7 @@ parcel Clownfish;
 
 class Clownfish::HashIterator nickname HashIter inherits Clownfish::Obj {
     Hash    *hash;
-    size_t   tick;
+    int32_t  tick;
     uint32_t capacity;
 
     inert void