[DEV]AB 1
[DEV]AB
kaptanmikro1 1
kaptanmikro1
emirhanHCL 1
emirhanHCL
farkmt2official 1
farkmt2official
Hikaye Ekle

CreateWhisper fix memory leak

  • Konuyu başlatan Konuyu başlatan banzai2
  • Başlangıç tarihi Başlangıç tarihi
  • Cevaplar Cevaplar 1
  • Görüntüleme Görüntüleme 290

Türkiye'de ilk Mobil & PC Aynı Anda Metin2 Oyna. Triarchonline kalıcı ve uzun ömürlü yapısı ile 24 Temmuz'da açılıyor. | 1-99 Mobil Metin2 Triarch HEMEN TIKLA!

std:🗺️:insert() does nothing when the key already exists. So every time CreateWhisper was called for an existing name (e.g. reopening a whisper window), a new CWhisper was allocated but never stored in the map and never freed — classic memory leak.

C++:
CWhisper * CPythonChat::CreateWhisper(const char * c_szName)
{
    CWhisper * pWhisper = CWhisper::New();
    m_WhisperMap.insert(TWhisperMap::value_type(c_szName, pWhisper));
    return pWhisper;
}

C++:
CWhisper * CPythonChat::CreateWhisper(const char * c_szName)
{
    TWhisperMap::iterator itor = m_WhisperMap.find(c_szName);
    if (itor != m_WhisperMap.end())
        return itor->second;

    CWhisper * pWhisper = CWhisper::New();
    m_WhisperMap.insert(TWhisperMap::value_type(c_szName, pWhisper));
    return pWhisper;
}
 

Şu an konuyu görüntüleyenler (Toplam : 0, Üye: 0, Misafir: 0)

Geri
Üst