examples

Toy examples in single C files.
git clone git://henryandlizzy.uk/examples
Log | Files | Refs

commit 335d5b90a0455229079ab2c2b449b0b3ce9c6d92
parent 81d627024d28dfe28d0d2d6896eb64e4a3b4e91a
Author: Henry Wilson <henry@henryandlizzy.uk>
Date:   Thu, 25 Apr 2024 23:21:08 +0100

Sanitiser options moved to files that use them

Diffstat:
Msrc/gl-3d.c | 4++--
Msrc/gl-asteroids.cpp | 4++--
Msrc/gl-lighting.c | 4++--
Msrc/gl.c | 4++--
Dsrc/sanitizer-options.h | 6------
Msrc/sdl.cpp | 9+++++----
6 files changed, 13 insertions(+), 18 deletions(-)

diff --git a/src/gl-3d.c b/src/gl-3d.c @@ -1,5 +1,3 @@ -#include "sanitizer-options.h" - #include <GLFW/glfw3.h> #include <assert.h> #include <math.h> @@ -11,6 +9,8 @@ #define MATRIX_GUARD glPushMatrix(); for (int i = 1; i--; glPopMatrix()) #define PROJECTION_GUARD glMatrixMode(GL_PROJECTION); for (int i = 1; i--; glMatrixMode(GL_MODELVIEW)) +char const* __asan_default_options() { return "detect_leaks=0"; } + struct vertex { float colour[3]; diff --git a/src/gl-asteroids.cpp b/src/gl-asteroids.cpp @@ -1,5 +1,3 @@ -#include "sanitizer-options.h" - #include <GLFW/glfw3.h> #include <alsa/asoundlib.h> #include <cmath> @@ -14,6 +12,8 @@ #include <optional> #include <functional> +extern "C" char const* __asan_default_options() { return "detect_leaks=0"; } + /// SOUNDS using sample = std::span<short>; diff --git a/src/gl-lighting.c b/src/gl-lighting.c @@ -1,5 +1,3 @@ -#include "sanitizer-options.h" - #include <GLFW/glfw3.h> #include <assert.h> #include <math.h> @@ -15,6 +13,8 @@ #define PROJECTION_GUARD glMatrixMode(GL_PROJECTION); for (int i = 1; i--; glMatrixMode(GL_MODELVIEW)) #define DRAW_GUARD(mode) glBegin(mode); for (int i = 1; i--; glEnd()) +char const* __asan_default_options() { return "detect_leaks=0"; } + struct vertex { float colour[3]; diff --git a/src/gl.c b/src/gl.c @@ -1,9 +1,9 @@ -#include "sanitizer-options.h" - #include <GLFW/glfw3.h> #include <assert.h> #include <math.h> +char const* __asan_default_options() { return "detect_leaks=0"; } + static void fb_resize_cb(GLFWwindow*, int w, int h) { glViewport(0, 0, w, h); diff --git a/src/sanitizer-options.h b/src/sanitizer-options.h @@ -1,6 +0,0 @@ -#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,12 +1,13 @@ -#include "sanitizer-options.h" - #include <SDL2/SDL.h> -int screen_width = 800; -int screen_height = 450; #define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a))) #define ARRAY_SSIZE(a) ((ssize_t)ARRAY_SIZE(a)) +extern "C" char const* __asan_default_options() { return "detect_leaks=0"; } + +int screen_width = 800; +int screen_height = 450; + SDL_Renderer* renderer; SDL_Window* window;