Skip to content

Commit

Permalink
Update to include allocate statement
Browse files Browse the repository at this point in the history
Another try
  • Loading branch information
chuckyvt committed Jul 10, 2024
1 parent 775be76 commit 154579e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/stdlib_hashmap_chaining.f90
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,10 @@ module subroutine map_chain_entry(map, key, other, conflict)
map % slots(hash_index) % target => new_ent
call copy_key( key, new_ent % key )
!if ( present(other) ) new_ent % other = other
if ( present(other) ) allocate(new_ent % other, source = other)
if ( present(other) ) then
if ALLOCATED(new_ent % other) deallocate(new_ent % other)
allocate(new_ent % other, source = other)
endif
if ( new_ent % inmap == 0 ) then
map % num_entries = map % num_entries + 1
inmap = map % num_entries
Expand Down
4 changes: 3 additions & 1 deletion src/stdlib_hashmap_open.f90
Original file line number Diff line number Diff line change
Expand Up @@ -553,9 +553,11 @@ module subroutine map_open_entry(map, key, other, conflict)
call allocate_open_map_entry(map, new_ent)
new_ent % hash_val = hash_val
call copy_key( key, new_ent % key )
if ( present( other ) ) &
if ( present( other ) ) then
!new_ent % other = other
if ALLOCATED(new_ent % other) deallocate(new_ent % other)
allocate(new_ent % other, source = other)
endif
inmap = new_ent % inmap
map % inverse( inmap ) % target => new_ent
map % slots( test_slot ) = inmap
Expand Down

0 comments on commit 154579e

Please sign in to comment.