Added functions to query and set the SDL memory allocation functions:
authorSam Lantinga <slouken@libsdl.org>
Thu, 12 Oct 2017 13:44:28 -0700
changeset 116106dea196ecbcb
parent 11607 db7ee6a1ba6a
child 11611 4ad5d0fccc9f
Added functions to query and set the SDL memory allocation functions:
SDL_GetMemoryFunctions()
SDL_SetMemoryFunctions()
SDL_GetNumAllocations()
CMakeLists.txt
VisualC/SDLtest/SDLtest.vcxproj
WhatsNew.txt
Xcode-iOS/SDLtest/SDL2test.xcodeproj/project.pbxproj
Xcode/SDLTest/SDLTest.xcodeproj/project.pbxproj
configure
configure.in
include/SDL_config.h.cmake
include/SDL_config.h.in
include/SDL_config_android.h
include/SDL_config_iphoneos.h
include/SDL_config_macosx.h
include/SDL_config_pandora.h
include/SDL_config_psp.h
include/SDL_config_wiz.h
include/SDL_stdinc.h
include/SDL_test.h
include/SDL_test_crc32.h
include/SDL_test_memory.h
src/dynapi/SDL_dynapi_overrides.h
src/dynapi/SDL_dynapi_procs.h
src/stdlib/SDL_malloc.c
src/stdlib/SDL_string.c
src/test/SDL_test_common.c
src/test/SDL_test_crc32.c
     1.1 --- a/CMakeLists.txt	Thu Oct 12 13:28:48 2017 -0700
     1.2 +++ b/CMakeLists.txt	Thu Oct 12 13:44:28 2017 -0700
     1.3 @@ -653,7 +653,7 @@
     1.4      check_include_file(sys/types.h HAVE_SYS_TYPES_H)
     1.5      foreach(_HEADER
     1.6              stdio.h stdlib.h stddef.h stdarg.h malloc.h memory.h string.h limits.h
     1.7 -            strings.h wchar.h inttypes.h stdint.h ctype.h math.h iconv.h signal.h)
     1.8 +            strings.h wchar.h inttypes.h stdint.h ctype.h math.h iconv.h signal.h libunwind.h)
     1.9        string(TOUPPER "HAVE_${_HEADER}" _UPPER)
    1.10        string(REPLACE "." "_" _HAVE_H ${_UPPER})
    1.11        check_include_file("${_HEADER}" ${_HAVE_H})
    1.12 @@ -669,7 +669,7 @@
    1.13      foreach(_FN
    1.14              strtod malloc calloc realloc free getenv setenv putenv unsetenv
    1.15              qsort abs bcopy memset memcpy memmove memcmp strlen strlcpy strlcat
    1.16 -            strdup _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa
    1.17 +            _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa
    1.18              _uitoa _ultoa strtol strtoul _i64toa _ui64toa strtoll strtoull
    1.19              atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp
    1.20              vsscanf vsnprintf fopen64 fseeko fseeko64 sigaction setjmp
     2.1 --- a/VisualC/SDLtest/SDLtest.vcxproj	Thu Oct 12 13:28:48 2017 -0700
     2.2 +++ b/VisualC/SDLtest/SDLtest.vcxproj	Thu Oct 12 13:44:28 2017 -0700
     2.3 @@ -164,9 +164,10 @@
     2.4      <ClCompile Include="..\..\src\test\SDL_test_imagePrimitivesBlend.c" />
     2.5      <ClCompile Include="..\..\src\test\SDL_test_log.c" />
     2.6      <ClCompile Include="..\..\src\test\SDL_test_md5.c" />
     2.7 +    <ClCompile Include="..\..\src\test\SDL_test_memory.c" />
     2.8      <ClCompile Include="..\..\src\test\SDL_test_random.c" />
     2.9    </ItemGroup>
    2.10    <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
    2.11    <ImportGroup Label="ExtensionTargets">
    2.12    </ImportGroup>
    2.13 -</Project>
    2.14 \ No newline at end of file
    2.15 +</Project>
     3.1 --- a/WhatsNew.txt	Thu Oct 12 13:28:48 2017 -0700
     3.2 +++ b/WhatsNew.txt	Thu Oct 12 13:44:28 2017 -0700
     3.3 @@ -6,6 +6,10 @@
     3.4  ---------------------------------------------------------------------------
     3.5  
     3.6  General:
     3.7 +* Added functions to query and set the SDL memory allocation functions:
     3.8 +	SDL_GetMemoryFunctions()
     3.9 +	SDL_SetMemoryFunctions()
    3.10 +	SDL_GetNumAllocations()
    3.11  * Added locking functions for multi-threaded access to the joystick and game controller APIs:
    3.12  	SDL_LockJoysticks()
    3.13  	SDL_UnlockJoysticks()
     4.1 --- a/Xcode-iOS/SDLtest/SDL2test.xcodeproj/project.pbxproj	Thu Oct 12 13:28:48 2017 -0700
     4.2 +++ b/Xcode-iOS/SDLtest/SDL2test.xcodeproj/project.pbxproj	Thu Oct 12 13:44:28 2017 -0700
     4.3 @@ -21,6 +21,8 @@
     4.4  		AA1EE46D176059AB0029C7A5 /* SDL_test_log.c in Sources */ = {isa = PBXBuildFile; fileRef = AA1EE45F176059AB0029C7A5 /* SDL_test_log.c */; };
     4.5  		AA1EE46E176059AB0029C7A5 /* SDL_test_md5.c in Sources */ = {isa = PBXBuildFile; fileRef = AA1EE460176059AB0029C7A5 /* SDL_test_md5.c */; };
     4.6  		AA1EE46F176059AB0029C7A5 /* SDL_test_random.c in Sources */ = {isa = PBXBuildFile; fileRef = AA1EE461176059AB0029C7A5 /* SDL_test_random.c */; };
     4.7 +		AAF030011F9009B100B9A9FB /* SDL_test_memory.c in Sources */ = {isa = PBXBuildFile; fileRef = AAF02FFF1F9009B100B9A9FB /* SDL_test_memory.c */; };
     4.8 +		AAF030021F9009B100B9A9FB /* SDL_test_assert.c in Sources */ = {isa = PBXBuildFile; fileRef = AAF030001F9009B100B9A9FB /* SDL_test_assert.c */; };
     4.9  		FA3D99011BC4E5BC002C96C8 /* SDL_test_common.c in Sources */ = {isa = PBXBuildFile; fileRef = AA1EE454176059AB0029C7A5 /* SDL_test_common.c */; };
    4.10  		FA3D99021BC4E5BC002C96C8 /* SDL_test_compare.c in Sources */ = {isa = PBXBuildFile; fileRef = AA1EE455176059AB0029C7A5 /* SDL_test_compare.c */; };
    4.11  		FA3D99031BC4E5BC002C96C8 /* SDL_test_crc32.c in Sources */ = {isa = PBXBuildFile; fileRef = AA1EE456176059AB0029C7A5 /* SDL_test_crc32.c */; };
    4.12 @@ -65,6 +67,8 @@
    4.13  		AA1EE45F176059AB0029C7A5 /* SDL_test_log.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = SDL_test_log.c; path = ../../src/test/SDL_test_log.c; sourceTree = "<group>"; };
    4.14  		AA1EE460176059AB0029C7A5 /* SDL_test_md5.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = SDL_test_md5.c; path = ../../src/test/SDL_test_md5.c; sourceTree = "<group>"; };
    4.15  		AA1EE461176059AB0029C7A5 /* SDL_test_random.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = SDL_test_random.c; path = ../../src/test/SDL_test_random.c; sourceTree = "<group>"; };
    4.16 +		AAF02FFF1F9009B100B9A9FB /* SDL_test_memory.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = SDL_test_memory.c; path = ../../src/test/SDL_test_memory.c; sourceTree = "<group>"; };
    4.17 +		AAF030001F9009B100B9A9FB /* SDL_test_assert.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = SDL_test_assert.c; path = ../../src/test/SDL_test_assert.c; sourceTree = "<group>"; };
    4.18  		FA3D98F81BC4E5A2002C96C8 /* libSDL2test-TV.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libSDL2test-TV.a"; sourceTree = BUILT_PRODUCTS_DIR; };
    4.19  /* End PBXFileReference section */
    4.20  
    4.21 @@ -106,6 +110,7 @@
    4.22  		AA1EE453176059770029C7A5 /* Library Source */ = {
    4.23  			isa = PBXGroup;
    4.24  			children = (
    4.25 +				AAF030001F9009B100B9A9FB /* SDL_test_assert.c */,
    4.26  				AA1EE454176059AB0029C7A5 /* SDL_test_common.c */,
    4.27  				AA1EE455176059AB0029C7A5 /* SDL_test_compare.c */,
    4.28  				AA1EE456176059AB0029C7A5 /* SDL_test_crc32.c */,
    4.29 @@ -119,6 +124,7 @@
    4.30  				AA1EE45E176059AB0029C7A5 /* SDL_test_imagePrimitivesBlend.c */,
    4.31  				AA1EE45F176059AB0029C7A5 /* SDL_test_log.c */,
    4.32  				AA1EE460176059AB0029C7A5 /* SDL_test_md5.c */,
    4.33 +				AAF02FFF1F9009B100B9A9FB /* SDL_test_memory.c */,
    4.34  				AA1EE461176059AB0029C7A5 /* SDL_test_random.c */,
    4.35  			);
    4.36  			name = "Library Source";
    4.37 @@ -213,12 +219,14 @@
    4.38  				AA1EE464176059AB0029C7A5 /* SDL_test_crc32.c in Sources */,
    4.39  				AA1EE465176059AB0029C7A5 /* SDL_test_font.c in Sources */,
    4.40  				AA1EE466176059AB0029C7A5 /* SDL_test_fuzzer.c in Sources */,
    4.41 +				AAF030021F9009B100B9A9FB /* SDL_test_assert.c in Sources */,
    4.42  				AA1EE467176059AB0029C7A5 /* SDL_test_harness.c in Sources */,
    4.43  				AA1EE468176059AB0029C7A5 /* SDL_test_imageBlit.c in Sources */,
    4.44  				AA1EE469176059AB0029C7A5 /* SDL_test_imageBlitBlend.c in Sources */,
    4.45  				AA1EE46A176059AB0029C7A5 /* SDL_test_imageFace.c in Sources */,
    4.46  				AA1EE46B176059AB0029C7A5 /* SDL_test_imagePrimitives.c in Sources */,
    4.47  				AA1EE46C176059AB0029C7A5 /* SDL_test_imagePrimitivesBlend.c in Sources */,
    4.48 +				AAF030011F9009B100B9A9FB /* SDL_test_memory.c in Sources */,
    4.49  				AA1EE46D176059AB0029C7A5 /* SDL_test_log.c in Sources */,
    4.50  				AA1EE46E176059AB0029C7A5 /* SDL_test_md5.c in Sources */,
    4.51  				AA1EE46F176059AB0029C7A5 /* SDL_test_random.c in Sources */,
     5.1 --- a/Xcode/SDLTest/SDLTest.xcodeproj/project.pbxproj	Thu Oct 12 13:28:48 2017 -0700
     5.2 +++ b/Xcode/SDLTest/SDLTest.xcodeproj/project.pbxproj	Thu Oct 12 13:44:28 2017 -0700
     5.3 @@ -348,6 +348,7 @@
     5.4  		00794EF009D23739003FC8A1 /* utf8.txt in CopyFiles */ = {isa = PBXBuildFile; fileRef = 00794E6309D20839003FC8A1 /* utf8.txt */; };
     5.5  		00794EF709D237DE003FC8A1 /* moose.dat in CopyFiles */ = {isa = PBXBuildFile; fileRef = 00794E5E09D20839003FC8A1 /* moose.dat */; };
     5.6  		453774A5120915E3002F0F45 /* testshape.c in Sources */ = {isa = PBXBuildFile; fileRef = 453774A4120915E3002F0F45 /* testshape.c */; };
     5.7 +		AAF02FFA1F90092700B9A9FB /* SDL_test_memory.c in Sources */ = {isa = PBXBuildFile; fileRef = AAF02FF41F90089800B9A9FB /* SDL_test_memory.c */; };
     5.8  		BBFC08C0164C6862003E6A99 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002F33A709CA188600EBEB88 /* Cocoa.framework */; };
     5.9  		BBFC08C1164C6862003E6A99 /* CoreAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A863B10730545007319AE /* CoreAudio.framework */; };
    5.10  		BBFC08C2164C6862003E6A99 /* ForceFeedback.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A863C10730545007319AE /* ForceFeedback.framework */; };
    5.11 @@ -1152,6 +1153,7 @@
    5.12  		092D6D75FFB313BB7F000001 /* testlock.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = testlock.c; path = ../../test/testlock.c; sourceTree = SOURCE_ROOT; };
    5.13  		4537749212091504002F0F45 /* testshape */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = testshape; sourceTree = BUILT_PRODUCTS_DIR; };
    5.14  		453774A4120915E3002F0F45 /* testshape.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = testshape.c; path = ../../test/testshape.c; sourceTree = SOURCE_ROOT; };
    5.15 +		AAF02FF41F90089800B9A9FB /* SDL_test_memory.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = SDL_test_memory.c; path = ../../src/test/SDL_test_memory.c; sourceTree = "<group>"; };
    5.16  		BBFC088E164C6820003E6A99 /* testgamecontroller.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = testgamecontroller.c; path = ../../test/testgamecontroller.c; sourceTree = "<group>"; };
    5.17  		BBFC08CD164C6862003E6A99 /* testgamecontroller */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = testgamecontroller; sourceTree = BUILT_PRODUCTS_DIR; };
    5.18  		BEC566B60761D90300A33029 /* checkkeys */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = checkkeys; sourceTree = BUILT_PRODUCTS_DIR; };
    5.19 @@ -2212,6 +2214,7 @@
    5.20  				DB166D8F16A1D1A500A1396C /* SDL_test_imagePrimitivesBlend.c */,
    5.21  				DB166D9016A1D1A500A1396C /* SDL_test_log.c */,
    5.22  				DB166D9116A1D1A500A1396C /* SDL_test_md5.c */,
    5.23 +				AAF02FF41F90089800B9A9FB /* SDL_test_memory.c */,
    5.24  				DB166D9216A1D1A500A1396C /* SDL_test_random.c */,
    5.25  			);
    5.26  			name = SDL_Test;
    5.27 @@ -3393,6 +3396,7 @@
    5.28  				DB166D9E16A1D1A500A1396C /* SDL_test_imagePrimitivesBlend.c in Sources */,
    5.29  				DB166D9F16A1D1A500A1396C /* SDL_test_log.c in Sources */,
    5.30  				DB166DA016A1D1A500A1396C /* SDL_test_md5.c in Sources */,
    5.31 +				AAF02FFA1F90092700B9A9FB /* SDL_test_memory.c in Sources */,
    5.32  				DB166DA116A1D1A500A1396C /* SDL_test_random.c in Sources */,
    5.33  			);
    5.34  			runOnlyForDeploymentPostprocessing = 0;
     6.1 --- a/configure	Thu Oct 12 13:28:48 2017 -0700
     6.2 +++ b/configure	Thu Oct 12 13:44:28 2017 -0700
     6.3 @@ -16635,7 +16635,7 @@
     6.4  rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
     6.5  fi
     6.6  
     6.7 -    for ac_func in malloc calloc realloc free getenv setenv putenv unsetenv qsort abs bcopy memset memcpy memmove wcslen wcscmp strlen strlcpy strlcat strdup _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa _uitoa _ultoa strtol strtoul _i64toa _ui64toa strtoll strtoull atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp vsscanf vsnprintf fopen64 fseeko fseeko64 sigaction setjmp nanosleep sysconf sysctlbyname getauxval poll
     6.8 +    for ac_func in malloc calloc realloc free getenv setenv putenv unsetenv qsort abs bcopy memset memcpy memmove wcslen wcscmp strlen strlcpy strlcat _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa _uitoa _ultoa strtol strtoul _i64toa _ui64toa strtoll strtoull atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp vsscanf vsnprintf fopen64 fseeko fseeko64 sigaction setjmp nanosleep sysconf sysctlbyname getauxval poll
     6.9  do :
    6.10    as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
    6.11  ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
    6.12 @@ -16761,6 +16761,19 @@
    6.13  
    6.14  fi
    6.15  
    6.16 +
    6.17 +	    for ac_header in libunwind.h
    6.18 +do :
    6.19 +  ac_fn_c_check_header_mongrel "$LINENO" "libunwind.h" "ac_cv_header_libunwind_h" "$ac_includes_default"
    6.20 +if test "x$ac_cv_header_libunwind_h" = xyes; then :
    6.21 +  cat >>confdefs.h <<_ACEOF
    6.22 +#define HAVE_LIBUNWIND_H 1
    6.23 +_ACEOF
    6.24 +
    6.25 +fi
    6.26 +
    6.27 +done
    6.28 +
    6.29  fi
    6.30  
    6.31  
     7.1 --- a/configure.in	Thu Oct 12 13:28:48 2017 -0700
     7.2 +++ b/configure.in	Thu Oct 12 13:44:28 2017 -0700
     7.3 @@ -268,7 +268,7 @@
     7.4          AC_DEFINE(HAVE_MPROTECT, 1, [ ])
     7.5          ]),
     7.6      )
     7.7 -    AC_CHECK_FUNCS(malloc calloc realloc free getenv setenv putenv unsetenv qsort abs bcopy memset memcpy memmove wcslen wcscmp strlen strlcpy strlcat strdup _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa _uitoa _ultoa strtol strtoul _i64toa _ui64toa strtoll strtoull atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp vsscanf vsnprintf fopen64 fseeko fseeko64 sigaction setjmp nanosleep sysconf sysctlbyname getauxval poll)
     7.8 +    AC_CHECK_FUNCS(malloc calloc realloc free getenv setenv putenv unsetenv qsort abs bcopy memset memcpy memmove wcslen wcscmp strlen strlcpy strlcat _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa _uitoa _ultoa strtol strtoul _i64toa _ui64toa strtoll strtoull atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp vsscanf vsnprintf fopen64 fseeko fseeko64 sigaction setjmp nanosleep sysconf sysctlbyname getauxval poll)
     7.9  
    7.10      AC_CHECK_LIB(m, pow, [LIBS="$LIBS -lm"; EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lm"])
    7.11      AC_CHECK_FUNCS(atan atan2 acos asin ceil copysign cos cosf fabs floor log pow scalbn sin sinf sqrt sqrtf tan tanf)
    7.12 @@ -277,6 +277,9 @@
    7.13      AC_CHECK_FUNCS(iconv)
    7.14  
    7.15      AC_CHECK_MEMBER(struct sigaction.sa_sigaction,[AC_DEFINE([HAVE_SA_SIGACTION], 1, [ ])], ,[#include <signal.h>])
    7.16 +
    7.17 +	dnl Check for additional non-standard headers
    7.18 +    AC_CHECK_HEADERS(libunwind.h)
    7.19  fi
    7.20  
    7.21  dnl AC_CHECK_SIZEOF(void*)
     8.1 --- a/include/SDL_config.h.cmake	Thu Oct 12 13:28:48 2017 -0700
     8.2 +++ b/include/SDL_config.h.cmake	Thu Oct 12 13:44:28 2017 -0700
     8.3 @@ -72,6 +72,7 @@
     8.4  #cmakedefine HAVE_SYS_TYPES_H 1
     8.5  #cmakedefine HAVE_WCHAR_H 1
     8.6  #cmakedefine HAVE_PTHREAD_NP_H 1
     8.7 +#cmakedefine HAVE_LIBUNWIND_H 1
     8.8  
     8.9  /* C library functions */
    8.10  #cmakedefine HAVE_MALLOC 1
    8.11 @@ -99,7 +100,6 @@
    8.12  #cmakedefine HAVE_STRLEN 1
    8.13  #cmakedefine HAVE_STRLCPY 1
    8.14  #cmakedefine HAVE_STRLCAT 1
    8.15 -#cmakedefine HAVE_STRDUP 1
    8.16  #cmakedefine HAVE__STRREV 1
    8.17  #cmakedefine HAVE__STRUPR 1
    8.18  #cmakedefine HAVE__STRLWR 1
     9.1 --- a/include/SDL_config.h.in	Thu Oct 12 13:28:48 2017 -0700
     9.2 +++ b/include/SDL_config.h.in	Thu Oct 12 13:44:28 2017 -0700
     9.3 @@ -75,6 +75,7 @@
     9.4  #undef HAVE_SYS_TYPES_H
     9.5  #undef HAVE_WCHAR_H
     9.6  #undef HAVE_PTHREAD_NP_H
     9.7 +#undef HAVE_LIBUNWIND_H
     9.8  
     9.9  /* C library functions */
    9.10  #undef HAVE_MALLOC
    9.11 @@ -102,7 +103,6 @@
    9.12  #undef HAVE_STRLEN
    9.13  #undef HAVE_STRLCPY
    9.14  #undef HAVE_STRLCAT
    9.15 -#undef HAVE_STRDUP
    9.16  #undef HAVE__STRREV
    9.17  #undef HAVE__STRUPR
    9.18  #undef HAVE__STRLWR
    10.1 --- a/include/SDL_config_android.h	Thu Oct 12 13:28:48 2017 -0700
    10.2 +++ b/include/SDL_config_android.h	Thu Oct 12 13:44:28 2017 -0700
    10.3 @@ -46,6 +46,7 @@
    10.4  #define HAVE_STDIO_H    1
    10.5  #define HAVE_STRING_H   1
    10.6  #define HAVE_SYS_TYPES_H    1
    10.7 +#define HAVE_LIBUNWIND_H    1
    10.8  
    10.9  /* C library functions */
   10.10  #define HAVE_MALLOC 1
   10.11 @@ -68,7 +69,6 @@
   10.12  #define HAVE_STRLEN 1
   10.13  #define HAVE_STRLCPY    1
   10.14  #define HAVE_STRLCAT    1
   10.15 -#define HAVE_STRDUP 1
   10.16  #define HAVE_STRCHR 1
   10.17  #define HAVE_STRRCHR    1
   10.18  #define HAVE_STRSTR 1
    11.1 --- a/include/SDL_config_iphoneos.h	Thu Oct 12 13:28:48 2017 -0700
    11.2 +++ b/include/SDL_config_iphoneos.h	Thu Oct 12 13:44:28 2017 -0700
    11.3 @@ -44,6 +44,7 @@
    11.4  #define HAVE_STDIO_H    1
    11.5  #define HAVE_STRING_H   1
    11.6  #define HAVE_SYS_TYPES_H    1
    11.7 +#define HAVE_LIBUNWIND_H    1
    11.8  
    11.9  /* C library functions */
   11.10  #define HAVE_MALLOC 1
   11.11 @@ -66,7 +67,6 @@
   11.12  #define HAVE_STRLEN 1
   11.13  #define HAVE_STRLCPY    1
   11.14  #define HAVE_STRLCAT    1
   11.15 -#define HAVE_STRDUP 1
   11.16  #define HAVE_STRCHR 1
   11.17  #define HAVE_STRRCHR    1
   11.18  #define HAVE_STRSTR 1
    12.1 --- a/include/SDL_config_macosx.h	Thu Oct 12 13:28:48 2017 -0700
    12.2 +++ b/include/SDL_config_macosx.h	Thu Oct 12 13:44:28 2017 -0700
    12.3 @@ -49,6 +49,7 @@
    12.4  #define HAVE_STDIO_H    1
    12.5  #define HAVE_STRING_H   1
    12.6  #define HAVE_SYS_TYPES_H    1
    12.7 +#define HAVE_LIBUNWIND_H    1
    12.8  
    12.9  /* C library functions */
   12.10  #define HAVE_MALLOC 1
   12.11 @@ -70,7 +71,6 @@
   12.12  #define HAVE_STRLEN 1
   12.13  #define HAVE_STRLCPY    1
   12.14  #define HAVE_STRLCAT    1
   12.15 -#define HAVE_STRDUP 1
   12.16  #define HAVE_STRCHR 1
   12.17  #define HAVE_STRRCHR    1
   12.18  #define HAVE_STRSTR 1
    13.1 --- a/include/SDL_config_pandora.h	Thu Oct 12 13:28:48 2017 -0700
    13.2 +++ b/include/SDL_config_pandora.h	Thu Oct 12 13:44:28 2017 -0700
    13.3 @@ -70,7 +70,6 @@
    13.4  #define HAVE_MEMCPY 1
    13.5  #define HAVE_MEMMOVE 1
    13.6  #define HAVE_STRLEN 1
    13.7 -#define HAVE_STRDUP 1
    13.8  #define HAVE_STRCHR 1
    13.9  #define HAVE_STRRCHR 1
   13.10  #define HAVE_STRSTR 1
    14.1 --- a/include/SDL_config_psp.h	Thu Oct 12 13:28:48 2017 -0700
    14.2 +++ b/include/SDL_config_psp.h	Thu Oct 12 13:44:28 2017 -0700
    14.3 @@ -66,7 +66,6 @@
    14.4  #define HAVE_STRLEN 1
    14.5  #define HAVE_STRLCPY    1
    14.6  #define HAVE_STRLCAT    1
    14.7 -#define HAVE_STRDUP 1
    14.8  #define HAVE_STRCHR 1
    14.9  #define HAVE_STRRCHR    1
   14.10  #define HAVE_STRSTR 1
    15.1 --- a/include/SDL_config_wiz.h	Thu Oct 12 13:28:48 2017 -0700
    15.2 +++ b/include/SDL_config_wiz.h	Thu Oct 12 13:44:28 2017 -0700
    15.3 @@ -64,7 +64,6 @@
    15.4  #define HAVE_MEMCPY 1
    15.5  #define HAVE_MEMMOVE 1
    15.6  #define HAVE_STRLEN 1
    15.7 -#define HAVE_STRDUP 1
    15.8  #define HAVE_STRCHR 1
    15.9  #define HAVE_STRRCHR 1
   15.10  #define HAVE_STRSTR 1
    16.1 --- a/include/SDL_stdinc.h	Thu Oct 12 13:28:48 2017 -0700
    16.2 +++ b/include/SDL_stdinc.h	Thu Oct 12 13:44:28 2017 -0700
    16.3 @@ -347,6 +347,37 @@
    16.4  extern DECLSPEC void *SDLCALL SDL_realloc(void *mem, size_t size);
    16.5  extern DECLSPEC void SDLCALL SDL_free(void *mem);
    16.6  
    16.7 +typedef void *(SDLCALL *SDL_malloc_func)(size_t size);
    16.8 +typedef void *(SDLCALL *SDL_calloc_func)(size_t nmemb, size_t size);
    16.9 +typedef void *(SDLCALL *SDL_realloc_func)(void *mem, size_t size);
   16.10 +typedef void (SDLCALL *SDL_free_func)(void *mem);
   16.11 +
   16.12 +/**
   16.13 + *  \brief Get the current set of SDL memory functions
   16.14 + */
   16.15 +extern DECLSPEC void SDLCALL SDL_GetMemoryFunctions(SDL_malloc_func *malloc_func,
   16.16 +                                                    SDL_calloc_func *calloc_func,
   16.17 +                                                    SDL_realloc_func *realloc_func,
   16.18 +                                                    SDL_free_func *free_func);
   16.19 +
   16.20 +/**
   16.21 + *  \brief Replace SDL's memory allocation functions with a custom set
   16.22 + *
   16.23 + *  \note If you are replacing SDL's memory functions, you should call
   16.24 + *        SDL_GetNumAllocations() and be very careful if it returns non-zero.
   16.25 + *        That means that your free function will be called with memory
   16.26 + *        allocated by the previous memory allocation functions.
   16.27 + */
   16.28 +extern DECLSPEC int SDLCALL SDL_SetMemoryFunctions(SDL_malloc_func malloc_func,
   16.29 +                                                   SDL_calloc_func calloc_func,
   16.30 +                                                   SDL_realloc_func realloc_func,
   16.31 +                                                   SDL_free_func free_func);
   16.32 +
   16.33 +/**
   16.34 + *  \brief Get the number of outstanding (unfreed) allocations
   16.35 + */
   16.36 +extern DECLSPEC int SDLCALL SDL_GetNumAllocations();
   16.37 +
   16.38  extern DECLSPEC char *SDLCALL SDL_getenv(const char *name);
   16.39  extern DECLSPEC int SDLCALL SDL_setenv(const char *name, const char *value, int overwrite);
   16.40  
    17.1 --- a/include/SDL_test.h	Thu Oct 12 13:28:48 2017 -0700
    17.2 +++ b/include/SDL_test.h	Thu Oct 12 13:44:28 2017 -0700
    17.3 @@ -31,17 +31,18 @@
    17.4  #define SDL_test_h_
    17.5  
    17.6  #include "SDL.h"
    17.7 +#include "SDL_test_assert.h"
    17.8  #include "SDL_test_common.h"
    17.9 +#include "SDL_test_compare.h"
   17.10 +#include "SDL_test_crc32.h"
   17.11  #include "SDL_test_font.h"
   17.12 -#include "SDL_test_random.h"
   17.13  #include "SDL_test_fuzzer.h"
   17.14 -#include "SDL_test_crc32.h"
   17.15 -#include "SDL_test_md5.h"
   17.16 -#include "SDL_test_log.h"
   17.17 -#include "SDL_test_assert.h"
   17.18  #include "SDL_test_harness.h"
   17.19  #include "SDL_test_images.h"
   17.20 -#include "SDL_test_compare.h"
   17.21 +#include "SDL_test_log.h"
   17.22 +#include "SDL_test_md5.h"
   17.23 +#include "SDL_test_memory.h"
   17.24 +#include "SDL_test_random.h"
   17.25  
   17.26  #include "begin_code.h"
   17.27  /* Set up for C function definitions, even when using C++ */
    18.1 --- a/include/SDL_test_crc32.h	Thu Oct 12 13:28:48 2017 -0700
    18.2 +++ b/include/SDL_test_crc32.h	Thu Oct 12 13:44:28 2017 -0700
    18.3 @@ -93,7 +93,7 @@
    18.4   * \returns 0 for OK, -1 on error
    18.5   *
    18.6   */
    18.7 -int SDLTest_crc32Calc(SDLTest_Crc32Context * crcContext, CrcUint8 *inBuf, CrcUint32 inLen, CrcUint32 *crc32);
    18.8 +int SDLTest_Crc32Calc(SDLTest_Crc32Context * crcContext, CrcUint8 *inBuf, CrcUint32 inLen, CrcUint32 *crc32);
    18.9  
   18.10  /* Same routine broken down into three steps */
   18.11  int SDLTest_Crc32CalcStart(SDLTest_Crc32Context * crcContext, CrcUint32 *crc32);
    19.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.2 +++ b/include/SDL_test_memory.h	Thu Oct 12 13:44:28 2017 -0700
    19.3 @@ -0,0 +1,63 @@
    19.4 +/*
    19.5 +  Simple DirectMedia Layer
    19.6 +  Copyright (C) 1997-2017 Sam Lantinga <slouken@libsdl.org>
    19.7 +
    19.8 +  This software is provided 'as-is', without any express or implied
    19.9 +  warranty.  In no event will the authors be held liable for any damages
   19.10 +  arising from the use of this software.
   19.11 +
   19.12 +  Permission is granted to anyone to use this software for any purpose,
   19.13 +  including commercial applications, and to alter it and redistribute it
   19.14 +  freely, subject to the following restrictions:
   19.15 +
   19.16 +  1. The origin of this software must not be misrepresented; you must not
   19.17 +     claim that you wrote the original software. If you use this software
   19.18 +     in a product, an acknowledgment in the product documentation would be
   19.19 +     appreciated but is not required.
   19.20 +  2. Altered source versions must be plainly marked as such, and must not be
   19.21 +     misrepresented as being the original software.
   19.22 +  3. This notice may not be removed or altered from any source distribution.
   19.23 +*/
   19.24 +
   19.25 +/**
   19.26 + *  \file SDL_test_memory.h
   19.27 + *
   19.28 + *  Include file for SDL test framework.
   19.29 + *
   19.30 + *  This code is a part of the SDL2_test library, not the main SDL library.
   19.31 + */
   19.32 +
   19.33 +#ifndef SDL_test_memory_h_
   19.34 +#define SDL_test_memory_h_
   19.35 +
   19.36 +#include "begin_code.h"
   19.37 +/* Set up for C function definitions, even when using C++ */
   19.38 +#ifdef __cplusplus
   19.39 +extern "C" {
   19.40 +#endif
   19.41 +
   19.42 +
   19.43 +/**
   19.44 + * \brief Start tracking SDL memory allocations
   19.45 + * 
   19.46 + * \note This should be called before any other SDL functions for complete tracking coverage
   19.47 + */
   19.48 +int SDLTest_TrackAllocations();
   19.49 +
   19.50 +/**
   19.51 + * \brief Print a log of any outstanding allocations
   19.52 + *
   19.53 + * \note This can be called after SDL_Quit()
   19.54 + */
   19.55 +void SDLTest_LogAllocations();
   19.56 +
   19.57 +
   19.58 +/* Ends C function definitions when using C++ */
   19.59 +#ifdef __cplusplus
   19.60 +}
   19.61 +#endif
   19.62 +#include "close_code.h"
   19.63 +
   19.64 +#endif /* SDL_test_memory_h_ */
   19.65 +
   19.66 +/* vi: set ts=4 sw=4 expandtab: */
    20.1 --- a/src/dynapi/SDL_dynapi_overrides.h	Thu Oct 12 13:28:48 2017 -0700
    20.2 +++ b/src/dynapi/SDL_dynapi_overrides.h	Thu Oct 12 13:44:28 2017 -0700
    20.3 @@ -637,3 +637,6 @@
    20.4  #define SDL_Vulkan_GetDrawableSize SDL_Vulkan_GetDrawableSize_REAL
    20.5  #define SDL_LockJoysticks SDL_LockJoysticks_REAL
    20.6  #define SDL_UnlockJoysticks SDL_UnlockJoysticks_REAL
    20.7 +#define SDL_GetMemoryFunctions SDL_GetMemoryFunctions_REAL
    20.8 +#define SDL_SetMemoryFunctions SDL_SetMemoryFunctions_REAL
    20.9 +#define SDL_GetNumAllocations SDL_GetNumAllocations_REAL
    21.1 --- a/src/dynapi/SDL_dynapi_procs.h	Thu Oct 12 13:28:48 2017 -0700
    21.2 +++ b/src/dynapi/SDL_dynapi_procs.h	Thu Oct 12 13:44:28 2017 -0700
    21.3 @@ -671,3 +671,6 @@
    21.4  SDL_DYNAPI_PROC(void,SDL_Vulkan_GetDrawableSize,(SDL_Window *a, int *b, int *c),(a,b,c),)
    21.5  SDL_DYNAPI_PROC(void,SDL_LockJoysticks,(void),(),)
    21.6  SDL_DYNAPI_PROC(void,SDL_UnlockJoysticks,(void),(),)
    21.7 +SDL_DYNAPI_PROC(void,SDL_GetMemoryFunctions,(SDL_malloc_func *a, SDL_calloc_func *b, SDL_realloc_func *c, SDL_free_func *d),(a,b,c,d),)
    21.8 +SDL_DYNAPI_PROC(int,SDL_SetMemoryFunctions,(SDL_malloc_func a, SDL_calloc_func b, SDL_realloc_func c, SDL_free_func d),(a,b,c,d),return)
    21.9 +SDL_DYNAPI_PROC(int,SDL_GetNumAllocations,(void),(),return)
    22.1 --- a/src/stdlib/SDL_malloc.c	Thu Oct 12 13:28:48 2017 -0700
    22.2 +++ b/src/stdlib/SDL_malloc.c	Thu Oct 12 13:44:28 2017 -0700
    22.3 @@ -26,39 +26,11 @@
    22.4  #include "../SDL_internal.h"
    22.5  
    22.6  /* This file contains portable memory management functions for SDL */
    22.7 -
    22.8  #include "SDL_stdinc.h"
    22.9 -
   22.10 -#if defined(HAVE_MALLOC)
   22.11 -
   22.12 -void *SDL_malloc(size_t size)
   22.13 -{
   22.14 -    if (!size) {
   22.15 -        return malloc(1);
   22.16 -    }
   22.17 -    return malloc(size);
   22.18 -}
   22.19 -
   22.20 -void *SDL_calloc(size_t nmemb, size_t size)
   22.21 -{
   22.22 -    if (!size || !nmemb) {
   22.23 -        return calloc(1,1);
   22.24 -    }
   22.25 -    return calloc(nmemb, size);
   22.26 -}
   22.27 -
   22.28 -void *SDL_realloc(void *ptr, size_t size)
   22.29 -{
   22.30 -    return realloc(ptr, size);
   22.31 -}
   22.32 -
   22.33 -void SDL_free(void *ptr)
   22.34 -{
   22.35 -    free(ptr);
   22.36 -}
   22.37 -
   22.38 -#else  /* the rest of this is a LOT of tapdancing to implement malloc. :) */
   22.39 -
   22.40 +#include "SDL_atomic.h"
   22.41 +#include "SDL_error.h"
   22.42 +
   22.43 +#ifndef HAVE_MALLOC
   22.44  #define LACKS_SYS_TYPES_H
   22.45  #define LACKS_STDIO_H
   22.46  #define LACKS_STRINGS_H
   22.47 @@ -66,6 +38,7 @@
   22.48  #define LACKS_STDLIB_H
   22.49  #define ABORT
   22.50  #define USE_LOCKS 1
   22.51 +#define USE_DL_PREFIX
   22.52  
   22.53  /*
   22.54    This is a version (aka dlmalloc) of malloc/free/realloc written by
   22.55 @@ -642,12 +615,12 @@
   22.56  #define MALLINFO_FIELD_TYPE size_t
   22.57  #endif /* MALLINFO_FIELD_TYPE */
   22.58  
   22.59 +#ifndef memset
   22.60  #define memset  SDL_memset
   22.61 +#endif
   22.62 +#ifndef memcpy
   22.63  #define memcpy  SDL_memcpy
   22.64 -#define malloc  SDL_malloc
   22.65 -#define calloc  SDL_calloc
   22.66 -#define realloc SDL_realloc
   22.67 -#define free    SDL_free
   22.68 +#endif
   22.69  
   22.70  /*
   22.71    mallopt tuning options.  SVID/XPG defines four standard parameter
   22.72 @@ -5271,4 +5244,133 @@
   22.73  
   22.74  #endif /* !HAVE_MALLOC */
   22.75  
   22.76 +#ifdef HAVE_MALLOC
   22.77 +#define real_malloc malloc
   22.78 +#define real_calloc calloc
   22.79 +#define real_realloc realloc
   22.80 +#define real_free free
   22.81 +#else
   22.82 +#define real_malloc dlmalloc
   22.83 +#define real_calloc dlcalloc
   22.84 +#define real_realloc dlrealloc
   22.85 +#define real_free dlfree
   22.86 +#endif
   22.87 +
   22.88 +/* Memory functions used by SDL that can be replaced by the application */
   22.89 +static struct
   22.90 +{
   22.91 +    SDL_malloc_func malloc_func;
   22.92 +    SDL_calloc_func calloc_func;
   22.93 +    SDL_realloc_func realloc_func;
   22.94 +    SDL_free_func free_func;
   22.95 +    SDL_atomic_t num_allocations;
   22.96 +} s_mem = {
   22.97 +    real_malloc, real_calloc, real_realloc, real_free, { 0 }
   22.98 +};
   22.99 +
  22.100 +void SDL_GetMemoryFunctions(SDL_malloc_func *malloc_func,
  22.101 +                            SDL_calloc_func *calloc_func,
  22.102 +                            SDL_realloc_func *realloc_func,
  22.103 +                            SDL_free_func *free_func)
  22.104 +{
  22.105 +    if (malloc_func) {
  22.106 +        *malloc_func = s_mem.malloc_func;
  22.107 +    }
  22.108 +    if (calloc_func) {
  22.109 +        *calloc_func = s_mem.calloc_func;
  22.110 +    }
  22.111 +    if (realloc_func) {
  22.112 +        *realloc_func = s_mem.realloc_func;
  22.113 +    }
  22.114 +    if (free_func) {
  22.115 +        *free_func = s_mem.free_func;
  22.116 +    }
  22.117 +}
  22.118 +
  22.119 +int SDL_SetMemoryFunctions(SDL_malloc_func malloc_func,
  22.120 +                           SDL_calloc_func calloc_func,
  22.121 +                           SDL_realloc_func realloc_func,
  22.122 +                           SDL_free_func free_func)
  22.123 +{
  22.124 +    if (!malloc_func) {
  22.125 +        return SDL_InvalidParamError("malloc_func");
  22.126 +    }
  22.127 +    if (!calloc_func) {
  22.128 +        return SDL_InvalidParamError("calloc_func");
  22.129 +    }
  22.130 +    if (!realloc_func) {
  22.131 +        return SDL_InvalidParamError("realloc_func");
  22.132 +    }
  22.133 +    if (!free_func) {
  22.134 +        return SDL_InvalidParamError("free_func");
  22.135 +    }
  22.136 +
  22.137 +    s_mem.malloc_func = malloc_func;
  22.138 +    s_mem.calloc_func = calloc_func;
  22.139 +    s_mem.realloc_func = realloc_func;
  22.140 +    s_mem.free_func = free_func;
  22.141 +    return 0;
  22.142 +}
  22.143 +
  22.144 +int SDL_GetNumAllocations()
  22.145 +{
  22.146 +    return SDL_AtomicGet(&s_mem.num_allocations);
  22.147 +}
  22.148 +
  22.149 +void *SDL_malloc(size_t size)
  22.150 +{
  22.151 +    void *mem;
  22.152 +
  22.153 +    if (!size) {
  22.154 +        size = 1;
  22.155 +    }
  22.156 +
  22.157 +    mem = s_mem.malloc_func(size);
  22.158 +    if (mem) {
  22.159 +        SDL_AtomicIncRef(&s_mem.num_allocations);
  22.160 +    }
  22.161 +    return mem;
  22.162 +}
  22.163 +
  22.164 +void *SDL_calloc(size_t nmemb, size_t size)
  22.165 +{
  22.166 +    void *mem;
  22.167 +
  22.168 +    if (!nmemb || !size) {
  22.169 +        nmemb = 1;
  22.170 +        size = 1;
  22.171 +    }
  22.172 +
  22.173 +    mem = s_mem.calloc_func(nmemb, size);
  22.174 +    if (mem) {
  22.175 +        SDL_AtomicIncRef(&s_mem.num_allocations);
  22.176 +    }
  22.177 +    return mem;
  22.178 +}
  22.179 +
  22.180 +void *SDL_realloc(void *ptr, size_t size)
  22.181 +{
  22.182 +    void *mem;
  22.183 +
  22.184 +    if (!ptr && !size) {
  22.185 +        size = 1;
  22.186 +    }
  22.187 +
  22.188 +    mem = s_mem.realloc_func(ptr, size);
  22.189 +    if (mem && !ptr) {
  22.190 +        SDL_AtomicIncRef(&s_mem.num_allocations);
  22.191 +    }
  22.192 +    return mem;
  22.193 +}
  22.194 +
  22.195 +void SDL_free(void *ptr)
  22.196 +{
  22.197 +    if (!ptr) {
  22.198 +        return;
  22.199 +    }
  22.200 +
  22.201 +    s_mem.free_func(ptr);
  22.202 +    SDL_AtomicDecRef(&s_mem.num_allocations);
  22.203 +}
  22.204 +
  22.205  /* vi: set ts=4 sw=4 expandtab: */
    23.1 --- a/src/stdlib/SDL_string.c	Thu Oct 12 13:28:48 2017 -0700
    23.2 +++ b/src/stdlib/SDL_string.c	Thu Oct 12 13:44:28 2017 -0700
    23.3 @@ -561,16 +561,12 @@
    23.4  char *
    23.5  SDL_strdup(const char *string)
    23.6  {
    23.7 -#if defined(HAVE_STRDUP)
    23.8 -    return strdup(string);
    23.9 -#else
   23.10      size_t len = SDL_strlen(string) + 1;
   23.11      char *newstr = SDL_malloc(len);
   23.12      if (newstr) {
   23.13          SDL_strlcpy(newstr, string, len);
   23.14      }
   23.15      return newstr;
   23.16 -#endif /* HAVE_STRDUP */
   23.17  }
   23.18  
   23.19  char *
    24.1 --- a/src/test/SDL_test_common.c	Thu Oct 12 13:28:48 2017 -0700
    24.2 +++ b/src/test/SDL_test_common.c	Thu Oct 12 13:44:28 2017 -0700
    24.3 @@ -47,7 +47,18 @@
    24.4  SDLTest_CommonState *
    24.5  SDLTest_CommonCreateState(char **argv, Uint32 flags)
    24.6  {
    24.7 -    SDLTest_CommonState *state = (SDLTest_CommonState *)SDL_calloc(1, sizeof(*state));
    24.8 +    int i;
    24.9 +    SDLTest_CommonState *state;
   24.10 +
   24.11 +    /* Do this first so we catch all allocations */
   24.12 +    for (i = 1; argv[i]; ++i) {
   24.13 +        if (SDL_strcasecmp(argv[i], "--trackmem") == 0) {
   24.14 +            SDLTest_TrackAllocations();
   24.15 +            break;
   24.16 +        }
   24.17 +    }
   24.18 +
   24.19 +    state = (SDLTest_CommonState *)SDL_calloc(1, sizeof(*state));
   24.20      if (!state) {
   24.21          SDL_OutOfMemory();
   24.22          return NULL;
   24.23 @@ -447,6 +458,10 @@
   24.24          state->audiospec.samples = (Uint16) SDL_atoi(argv[index]);
   24.25          return 2;
   24.26      }
   24.27 +    if (SDL_strcasecmp(argv[index], "--trackmem") == 0) {
   24.28 +        /* Already handled in SDLTest_CommonCreateState() */
   24.29 +        return 1;
   24.30 +    }
   24.31      if ((SDL_strcasecmp(argv[index], "-h") == 0)
   24.32          || (SDL_strcasecmp(argv[index], "--help") == 0)) {
   24.33          /* Print the usage message */
   24.34 @@ -464,13 +479,13 @@
   24.35  {
   24.36      switch (state->flags & (SDL_INIT_VIDEO | SDL_INIT_AUDIO)) {
   24.37      case SDL_INIT_VIDEO:
   24.38 -        return VIDEO_USAGE;
   24.39 +        return "[--trackmem] " VIDEO_USAGE;
   24.40      case SDL_INIT_AUDIO:
   24.41 -        return AUDIO_USAGE;
   24.42 +        return "[--trackmem] " AUDIO_USAGE;
   24.43      case (SDL_INIT_VIDEO | SDL_INIT_AUDIO):
   24.44 -        return VIDEO_USAGE " " AUDIO_USAGE;
   24.45 +        return "[--trackmem] " VIDEO_USAGE " " AUDIO_USAGE;
   24.46      default:
   24.47 -        return "";
   24.48 +        return "[--trackmem]";
   24.49      }
   24.50  }
   24.51  
   24.52 @@ -1762,6 +1777,7 @@
   24.53      }
   24.54      SDL_free(state);
   24.55      SDL_Quit();
   24.56 +    SDLTest_LogAllocations();
   24.57  }
   24.58  
   24.59  /* vi: set ts=4 sw=4 expandtab: */
    25.1 --- a/src/test/SDL_test_crc32.c	Thu Oct 12 13:28:48 2017 -0700
    25.2 +++ b/src/test/SDL_test_crc32.c	Thu Oct 12 13:44:28 2017 -0700
    25.3 @@ -69,7 +69,6 @@
    25.4  }
    25.5  
    25.6  /* Complete CRC32 calculation on a memory block */
    25.7 -/* un-used
    25.8  int SDLTest_Crc32Calc(SDLTest_Crc32Context * crcContext, CrcUint8 *inBuf, CrcUint32 inLen, CrcUint32 *crc32)
    25.9  {
   25.10    if (SDLTest_Crc32CalcStart(crcContext,crc32)) {
   25.11 @@ -86,7 +85,6 @@
   25.12  
   25.13    return 0;
   25.14  }
   25.15 -*/
   25.16  
   25.17  /* Start crc calculation */
   25.18