libretro / beetle-bsnes-libretro

Standalone port of Mednafen bSNES to libretro, itself a fork of bsnes 0.59.
GNU General Public License v2.0
7 stars 14 forks source link

mednafen: use std::vector and std::array instead of manual memory allocations #45

Open lrusak opened 1 year ago

lrusak commented 1 year ago

This also fixes the following problems (#42) :

mednafen/mednafen.cpp: In function ‘void MDFN_printf(const char*, ...)’: mednafen/mednafen.cpp:246:8: warning: ‘void free(void*)’ called on pointer returned from a mismatched allocation function [-Wmismatched-new-delete]
  246 |    free(temp);
      |    ~~~~^~~~~~
mednafen/mednafen.cpp:241:24: note: returned from ‘void* operator new [](std::size_t)’
  241 |    temp = new char[4096];
      |                        ^
mednafen/mednafen.cpp: In function ‘void MDFN_PrintError(const char*, ...)’:
mednafen/mednafen.cpp:262:6: warning: ‘void free(void*)’ called on pointer returned from a mismatched allocation function [-Wmismatched-new-delete]
  262 |  free(temp);
      |  ~~~~^~~~~~
mednafen/mednafen.cpp:259:22: note: returned from ‘void* operator new [](std::size_t)’
  259 |  temp = new char[4096];
      |                      ^
mednafen/mednafen.cpp: In function ‘void MDFN_DebugPrintReal(const char*, int, const char*, ...)’:
mednafen/mednafen.cpp:278:6: warning: ‘void free(void*)’ called on pointer returned from a mismatched allocation function [-Wmismatched-new-delete]
  278 |  free(temp);
      |  ~~~~^~~~~~
mednafen/mednafen.cpp:275:22: note: returned from ‘void* operator new [](std::size_t)’
  275 |  temp = new char[4096];
      |                      ^
LibretroAdmin commented 1 year ago

Is there a way you can fix these warnings/issues without resorting to the STL? No C++ code but C code?

lrusak commented 1 year ago

Is there a way you can fix these warnings/issues without resorting to the STL? No C++ code but C code?

Sure, what's the reason?

lrusak commented 1 year ago

I've pushed some commits that I can squash down if it's acceptable.