commit 5f86adcc15715188678dcda4bcca1e09de7f32f7
parent 075b99077776c91d92d3a07cf0f6e62754856b1e
Author: Henry Wilson <henry@henryandlizzy.uk>
Date: Fri, 22 Sep 2023 21:19:39 +0100
Add address sanitizer leak detection suppression for programs that need it
Diffstat:
7 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/src/gl-3d.c b/src/gl-3d.c
@@ -1,3 +1,5 @@
+#include "sanitizer-options.h"
+
#include <GLFW/glfw3.h>
#include <assert.h>
#include <math.h>
diff --git a/src/gl-asteroids.cpp b/src/gl-asteroids.cpp
@@ -1,3 +1,5 @@
+#include "sanitizer-options.h"
+
#include <GLFW/glfw3.h>
#include <alsa/asoundlib.h>
#include <cmath>
diff --git a/src/gl-lighting.c b/src/gl-lighting.c
@@ -1,3 +1,5 @@
+#include "sanitizer-options.h"
+
#include <GLFW/glfw3.h>
#include <assert.h>
#include <math.h>
diff --git a/src/gl.c b/src/gl.c
@@ -1,3 +1,5 @@
+#include "sanitizer-options.h"
+
#include <GLFW/glfw3.h>
#include <assert.h>
diff --git a/src/glob.c b/src/glob.c
@@ -13,6 +13,9 @@ int main(int argc, char* argv[])
int flags = GLOB_NOSORT;
glob_t results = {0};
+ if (argc < 2)
+ return 0;
+
for (int i = 1; i < argc; ++i)
{
glob(argv[i], flags, NULL, &results);
@@ -24,4 +27,5 @@ int main(int argc, char* argv[])
for (size_t i = 0; i < results.gl_pathc; ++i)
puts(results.gl_pathv[i]);
+ globfree(&results);
}
diff --git a/src/sanitizer-options.h b/src/sanitizer-options.h
@@ -0,0 +1,6 @@
+#pragma once
+
+#ifdef __cplusplus
+extern "C"
+#endif
+char const* __asan_default_options() { return "detect_leaks=0"; }
diff --git a/src/sdl.cpp b/src/sdl.cpp
@@ -1,5 +1,6 @@
-#include <SDL2/SDL.h>
+#include "sanitizer-options.h"
+#include <SDL2/SDL.h>
int screen_width = 800;
int screen_height = 450;