From 251a2457fe10910b357e33609a59545684294bc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Fri, 2 Feb 2018 00:53:17 +0100 Subject: Add the get_num_allocations function No corresponding Erlang module, only callable via esdl2. Don't really need much more than that. --- c_src/esdl2.h | 2 ++ c_src/sdl_bool.c | 21 --------------------- c_src/sdl_stdinc.c | 28 ++++++++++++++++++++++++++++ src/esdl2.erl | 8 ++++++++ 4 files changed, 38 insertions(+), 21 deletions(-) delete mode 100644 c_src/sdl_bool.c create mode 100644 c_src/sdl_stdinc.c diff --git a/c_src/esdl2.h b/c_src/esdl2.h index d4aa683..e4f0356 100644 --- a/c_src/esdl2.h +++ b/c_src/esdl2.h @@ -402,6 +402,8 @@ F(render_target_supported, 1) \ F(set_render_draw_blend_mode, 2) \ F(set_render_draw_color, 5) \ + /* sdl_stdinc */ \ + F(get_num_allocations, 0) \ /* sdl_surface */ \ F(img_load, 1) \ /* sdl_texture */ \ diff --git a/c_src/sdl_bool.c b/c_src/sdl_bool.c deleted file mode 100644 index 5c90503..0000000 --- a/c_src/sdl_bool.c +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 2014-2018, Loïc Hoguin -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -#include "esdl2.h" - -#define BOOL_ENUM(E) \ - E(false, SDL_FALSE) \ - E(true, SDL_TRUE) - -NIF_ATOM_TO_ENUM_FUNCTION(atom_to_bool, SDL_bool, BOOL_ENUM) diff --git a/c_src/sdl_stdinc.c b/c_src/sdl_stdinc.c new file mode 100644 index 0000000..9aef17e --- /dev/null +++ b/c_src/sdl_stdinc.c @@ -0,0 +1,28 @@ +// Copyright (c) 2014-2018, Loïc Hoguin +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +#include "esdl2.h" + +#define BOOL_ENUM(E) \ + E(false, SDL_FALSE) \ + E(true, SDL_TRUE) + +NIF_ATOM_TO_ENUM_FUNCTION(atom_to_bool, SDL_bool, BOOL_ENUM) + +// get_num_allocations + +NIF_FUNCTION(get_num_allocations) +{ + return enif_make_int(env, SDL_GetNumAllocations()); +} diff --git a/src/esdl2.erl b/src/esdl2.erl index 747b74e..2198d60 100644 --- a/src/esdl2.erl +++ b/src/esdl2.erl @@ -156,6 +156,9 @@ -export([set_render_draw_blend_mode/2]). -export([set_render_draw_color/5]). +%% sdl_stdinc +-export([get_num_allocations/0]). + %% sdl_surface -export([img_load/1]). @@ -612,6 +615,11 @@ set_render_draw_blend_mode(_, _) -> set_render_draw_color(_, _, _, _, _) -> erlang:nif_error({not_loaded, ?MODULE}). +%% sdl_stdinc + +get_num_allocations() -> + erlang:nif_error({not_loaded, ?MODULE}). + %% sdl_surface img_load(_) -> -- cgit v1.2.3