Skip to content

Commit 07febc3

Browse files
committed
Revert "Reverting back to in-line allocation"
This reverts commit 3c60ba4.
1 parent ac93bca commit 07febc3

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/stdlib_hashmap_chaining.f90

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,11 @@ module subroutine map_chain_entry(map, key, other, conflict)
569569
new_ent % next => map % slots(hash_index) % target
570570
map % slots(hash_index) % target => new_ent
571571
call copy_key( key, new_ent % key )
572-
if ( present(other) ) new_ent % other = other
572+
!if ( present(other) ) new_ent % other = 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
573577
if ( new_ent % inmap == 0 ) then
574578
map % num_entries = map % num_entries + 1
575579
inmap = map % num_entries

src/stdlib_hashmap_open.f90

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +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 ) ) new_ent % other = other
556+
if ( present( other ) ) then
557+
!new_ent % other = other
558+
if ( allocated(new_ent % other) ) deallocate(new_ent % other)
559+
allocate(new_ent % other, source = other)
560+
endif
557561
inmap = new_ent % inmap
558562
map % inverse( inmap ) % target => new_ent
559563
map % slots( test_slot ) = inmap

0 commit comments

Comments
 (0)