@@ -73,7 +73,7 @@ namespace grb {
7373 lpf_rc = lpf_rc ? lpf_rc : lpf_sync ( data.context , LPF_SYNC_DEFAULT );
7474
7575 data.signalMemslotTaken ();
76- data.registered_slots .insert ({ buf, std::make_pair ( size, memslot ) });
76+ data.registered_slots .insert ({ buf, grb::internal::registered_slot (buf, memslot, size, true ) });
7777 data.global_memslots .insert ({ memslot, buf });
7878
7979 if ( lpf_rc == LPF_SUCCESS ) {
@@ -105,7 +105,7 @@ namespace grb {
105105 const auto it0 = data.registered_slots .find ( buf );
106106 assert ( it0 != data.registered_slots .end () );
107107
108- memslot = it0->second .second ;
108+ memslot = it0->second .slot ;
109109 data.registered_slots .erase ( it0 );
110110
111111 const auto it1 = data.global_memslots .find ( memslot );
@@ -163,18 +163,20 @@ namespace grb {
163163 {
164164 const auto it = data.registered_slots .find ( src );
165165 assert ( it != data.registered_slots .end () );
166- assert ( it->second .first >= size );
167- src_memslot = it->second .second ;
166+ assert ( it->second .size >= size );
167+ assert ( it->second .global );
168+ src_memslot = it->second .slot ;
168169 }
169170
170171 const auto it = data.registered_slots .find ( dst );
171172 if ( it == data.registered_slots .end () ){
172173 lpf_rc = lpf_rc ? lpf_rc : lpf_register_local ( data.context , const_cast < void * >( dst ), size, &dst_memslot );
173174 data.signalMemslotTaken ();
175+ data.registered_slots .insert ({dst, grb::internal::registered_slot ( dst, dst_memslot, size, false )});
174176 } else {
175- assert ( it->first == dst );
176- assert ( it->second .first >= size );
177- dst_memslot = it->second .second ;
177+ assert ( it->second . buf == dst );
178+ assert ( it->second .size >= size );
179+ dst_memslot = it->second .slot ;
178180 }
179181
180182 lpf_rc = lpf_rc ? lpf_rc : lpf_get ( data.context , src_pid, src_memslot , 0 , dst_memslot, 0 , size, lpf_attr );
@@ -229,18 +231,21 @@ namespace grb {
229231 {
230232 const auto it = data.registered_slots .find ( dst );
231233 assert ( it != data.registered_slots .end () );
232- assert ( it->second .first >= size );
233- dst_memslot = it->second .second ;
234+ assert ( it->second .buf == dst );
235+ assert ( it->second .size >= size );
236+ assert ( it->second .global );
237+ dst_memslot = it->second .slot ;
234238 }
235239
236240 const auto it = data.registered_slots .find ( src );
237241 if ( it == data.registered_slots .end () ){
238242 lpf_rc = lpf_rc ? lpf_rc : lpf_register_local ( data.context , const_cast < void * >( src ), size, &src_memslot );
239243 data.signalMemslotTaken ();
244+ data.registered_slots .insert ({src, grb::internal::registered_slot ( src, src_memslot, size, false )});
240245 } else {
241- assert ( it->first == src );
242- assert ( it->second .first >= size ); // is there enough space?
243- src_memslot = it->second .second ;
246+ assert ( it->second . buf == src );
247+ assert ( it->second .size >= size ); // is there enough space?
248+ src_memslot = it->second .slot ;
244249 }
245250
246251 lpf_rc = lpf_rc ? lpf_rc : lpf_put ( data.context , src_memslot, 0 , dst_pid, dst_memslot, 0 , size, lpf_attr );
0 commit comments