Commit c40e8e07 authored by Keith Bennett's avatar Keith Bennett

Fixed allocation bugs in hash_table implementation

parent 4bdbed08
...@@ -752,6 +752,7 @@ CONTAINS ...@@ -752,6 +752,7 @@ CONTAINS
var%time = 0 var%time = 0
DO i = 1, hash_size DO i = 1, hash_size
NULLIFY(var%hash_table(i)%block) NULLIFY(var%hash_table(i)%block)
NULLIFY(var%hash_table(i)%next)
END DO END DO
var%summary_location_wrote = var%summary_location var%summary_location_wrote = var%summary_location
...@@ -1001,7 +1002,7 @@ CONTAINS ...@@ -1001,7 +1002,7 @@ CONTAINS
TYPE(sdf_file_handle), INTENT(INOUT) :: h TYPE(sdf_file_handle), INTENT(INOUT) :: h
TYPE(sdf_block_type), POINTER , INTENT(IN):: b TYPE(sdf_block_type), POINTER , INTENT(IN):: b
TYPE(sdf_hash_list), POINTER :: hash_item, new_hash_item TYPE(sdf_hash_list), POINTER :: hash_item
INTEGER :: i INTEGER :: i
IF (h%writing_summary) RETURN IF (h%writing_summary) RETURN
...@@ -1010,12 +1011,17 @@ CONTAINS ...@@ -1010,12 +1011,17 @@ CONTAINS
i = INT(MOD(ABS(b%id_hash), hash_size)) + 1 i = INT(MOD(ABS(b%id_hash), hash_size)) + 1
IF (ASSOCIATED(h%hash_table(i)%block)) THEN IF (ASSOCIATED(h%hash_table(i)%block)) THEN
hash_item => h%hash_table(i)%next IF (ASSOCIATED(h%hash_table(i)%next)) THEN
DO WHILE (ASSOCIATED(hash_item)) hash_item => h%hash_table(i)%next
DO WHILE (ASSOCIATED(hash_item%next))
hash_item => hash_item%next
END DO
ALLOCATE(hash_item%next)
hash_item => hash_item%next hash_item => hash_item%next
END DO ELSE
ALLOCATE(new_hash_item) ALLOCATE(h%hash_table(i)%next)
hash_item => new_hash_item hash_item => h%hash_table(i)%next
END IF
hash_item%block => b hash_item%block => b
NULLIFY(hash_item%next) NULLIFY(hash_item%next)
ELSE ELSE
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment