# Shared libaries are big piece of crap, leaking memory so badly that you cannot see your own messages in the noise.
# We call Mix_CloseAudio() and SDL_Quit() properly, so this isn't on us. Therefore exclude leak reports from libraries
# that libSDL loads with Mix_OpenAudio() or SDL_init()
# use as: valgrind --suppressions=libSDL.supp --leak-check=full --show-leak-kinds=all --num-callers=20 ./tngp

# yeah, SDL_Init isn't really a function, you cannot match that
{
   library_memleaks_calloc
   Memcheck:Leak
   fun:calloc
   ...
   fun:SDL_InitSubSystem_REAL
}
{
   library_memleaks_realloc
   Memcheck:Leak
   fun:realloc
   ...
   fun:SDL_InitSubSystem_REAL
}
{
   library_memleaks_malloc
   Memcheck:Leak
   fun:malloc
   ...
   fun:SDL_InitSubSystem_REAL
}
{
   library_memleaks_calloc2
   Memcheck:Leak
   fun:calloc
   ...
   fun:SDL_VideoInit_REAL
}
{
   library_memleaks_realloc2
   Memcheck:Leak
   fun:realloc
   ...
   fun:SDL_VideoInit_REAL
}
{
   library_memleaks_malloc2
   Memcheck:Leak
   fun:malloc
   ...
   fun:SDL_VideoInit_REAL
}

# exclude Mix_OpenAudio() stuff (libasound in particular) that runs in a separate thread and not freed by Mix_CloseAudio()
{
   library_memleaks_calloc3
   Memcheck:Leak
   fun:calloc
   ...
   fun:snd_*
}
{
   library_memleaks_realloc3
   Memcheck:Leak
   fun:realloc
   ...
   fun:snd_*
}
{
   library_memleaks_malloc3
   Memcheck:Leak
   fun:malloc
   ...
   fun:snd_*
}

# exclude libX11 leak. Not our fault either, we don't allocate any cursor at all...
{
   library_memleaks_malloc4
   Memcheck:Leak
   fun:malloc
   ...
   fun:SDL_SetCursor_REAL
}

# finally exclude leaks in libdl itself during exit... This isn't a joke: freeing everything properly causes memleak!
{
   library_memleaks_malloc5
   Memcheck:Leak
   fun:malloc
   ...
   fun:_dl_close
}
{
   library_memleaks_malloc6
   Memcheck:Leak
   fun:malloc
   ...
   fun:_dl_open
}
{
   library_memleaks_calloc4
   Memcheck:Leak
   fun:calloc
   ...
   fun:_dl_open
}
{
   library_memleaks_malloc7
   Memcheck:Leak
   fun:malloc
   ...
   fun:tls_get_addr_tail
}

#...oh, and valgrind leaks...
{
   library_valgrind
   Memcheck:Leak
   obj:/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so
#   fun:operator new     (how the f does one reference the new operator???)
   ...
   fun:_dl_open
}
