### This file contains Valgrind suppressions to use when running GDAL unit tests.
###
### It should be used alongside the suppressions provided by Python at https://github.com/python/cpython/blob/main/Misc/valgrind-python.supp
### (possibly modified according to the instructions found within that file)

### Suppress errors generated by tests of VSIMalloc error handling

{
   memalign/fishy
   Memcheck:FishyValue
   memalign(size)
   ...
   fun:*VSIMalloc*_Test*
}

{
   memalign/fishy
   Memcheck:FishyValue
   calloc(nmemb)
   ...
   fun:*VSIMalloc_Test*
}

{
   memalign/fishy
   Memcheck:FishyValue
   malloc(size)
   ...
   fun:*VSIMalloc_Test*
}

{
   memalign/fishy
   Memcheck:FishyValue
   malloc(size)
   ...
   fun:*VSIMalloc_Test*
}

### Suppress leaks in SWIG

{
    SWIG leak: https://github.com/swig/swig/issues/1985
    Memcheck:Leak
    match-leak-kinds: definite
    fun:malloc
    fun:SwigPyClientData_New 
}

### Suppress errors in getenv

{
   getenv/Invalid read of size 2
   Memcheck:Addr2
   fun:getenv
}

{
   getenv/jump
   Memcheck:Cond
   fun:getenv
}

### Suppress errors in dlopen

{
    dlopen
    Memcheck:Addr8
    ...
    fun:dl_open_worker
}

{
    dlopen leak
    Memcheck:Leak
    match-leak-kinds: all
    fun:malloc
    ...
    fun:dl_open_worker
}

### Suppress leak warnings from allocations done within Python

{
    python
    Memcheck:Leak
    match-leak-kinds: all
    fun:*alloc
    obj:/usr/bin/python3.10
    ...
}

 
{
    numpy
    Memcheck:Leak
    match-leak-kinds: all
    fun:*alloc
    ...
    fun:PyInit__multiarray_umath
}
