- if (sendbuffer_size<size){
- sendbuffer=static_cast<char*>(xbt_realloc(sendbuffer,size));
- sendbuffer_size=size;
+
+ // check if the process is registered
+ aid_t id = simgrid::s4u::this_actor::get_pid();
+ if (buffer_map->find(id) == buffer_map->end()) {
+ // This tuple represents a buffer and his size
+ buffer_tuple buffer_tuple(nullptr, 0);
+ (*buffer_map)[id] = buffer_tuple;
+ simgrid::s4u::this_actor::on_exit(
+ [id, buffer_map](int status, void* ignored) {
+ xbt_free(std::get<0>((*buffer_map)[id]));
+ std::get<0>((*buffer_map)[id]) = nullptr;
+ },
+ nullptr);