LoginSignup
0
0

More than 5 years have passed since last update.

STLのmapでメモリリーク

Posted at

valgrindのチェックでひっかかった

mapTmp[key] = value;

みたいな使い方をしていたらおこられたので

auto find = mapTmp.find(key);
if(find == mapTmp.end()){
     mapTmp[key] = value;
}else{
     find->second = value;
}

こうした。
でもまだおこられてたので

auto find = mapTmp.find(key);
if(find == mapTmp.end()){
     mapTmp.insert(std::make_pair(key,value));
}else{
     find->second = value;
}

結局こうなった。

0
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0