if(shared_block_offsets[0] > 0) {
newmeta.private_blocks.push_back(std::make_pair(0, shared_block_offsets[0]));
}
- for(int i_block = 0; i_block < nb_shared_blocks-1; i_block ++) {
+ int i_block;
+ for(i_block = 0; i_block < nb_shared_blocks-1; i_block ++) {
newmeta.private_blocks.push_back(std::make_pair(shared_block_offsets[2*i_block+1], shared_block_offsets[2*i_block+2]));
}
- if(shared_block_offsets[nb_shared_blocks-1] < size) {
- newmeta.private_blocks.push_back(std::make_pair(shared_block_offsets[nb_shared_blocks-1], size));
+ if(shared_block_offsets[2*i_block+1] < size) {
+ newmeta.private_blocks.push_back(std::make_pair(shared_block_offsets[2*i_block+1], size));
}
allocs_metadata[mem] = newmeta;
return 0;
low --;
if (ptr < (char*)low->first + low->second.size) {
- *offset = ((uint8_t*) low->first) - ((uint8_t*)ptr);
+ xbt_assert(ptr > (char*)low->first, "Oops, there seems to be a bug in the shared memory metadata.");
+ *offset = ((uint8_t*)ptr) - ((uint8_t*) low->first);
private_blocks = low->second.private_blocks;
return 1;
}