Skip to content

Commit 3e5c9a6

Browse files
committed
Update to include allocate statement
Another try
1 parent 8c9f2fa commit 3e5c9a6

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/stdlib_hashmap_chaining.f90

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,10 @@ module subroutine map_chain_entry(map, key, other, conflict)
570570
map % slots(hash_index) % target => new_ent
571571
call copy_key( key, new_ent % key )
572572
!if ( present(other) ) new_ent % other = other
573-
if ( present(other) ) allocate(new_ent % other, source = other)
573+
if ( present(other) ) then
574+
if ALLOCATED(new_ent % other) deallocate(new_ent % other)
575+
allocate(new_ent % other, source = other)
576+
endif
574577
if ( new_ent % inmap == 0 ) then
575578
map % num_entries = map % num_entries + 1
576579
inmap = map % num_entries

src/stdlib_hashmap_open.f90

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,9 +553,11 @@ module subroutine map_open_entry(map, key, other, conflict)
553553
call allocate_open_map_entry(map, new_ent)
554554
new_ent % hash_val = hash_val
555555
call copy_key( key, new_ent % key )
556-
if ( present( other ) ) &
556+
if ( present( other ) ) then
557557
!new_ent % other = other
558+
if ALLOCATED(new_ent % other) deallocate(new_ent % other)
558559
allocate(new_ent % other, source = other)
560+
endif
559561
inmap = new_ent % inmap
560562
map % inverse( inmap ) % target => new_ent
561563
map % slots( test_slot ) = inmap

0 commit comments

Comments
 (0)