From 167bbf44eec3c76a63a6a14319136a3ee3a3c0ac Mon Sep 17 00:00:00 2001 From: hgn Date: Sat, 15 Apr 2023 01:57:18 +0100 Subject: [PATCH] memory related functions --- vg.h | 94 ++++++++++++++++++++++++--------------------------- vg_mem.h | 5 ++- vg_platform.h | 11 +++--- 3 files changed, 52 insertions(+), 58 deletions(-) diff --git a/vg.h b/vg.h index 141bea3..777a9e3 100644 --- a/vg.h +++ b/vg.h @@ -61,31 +61,6 @@ */ -#ifdef VG_RELEASE - #define VG_STATIC static -#else - #define VG_STATIC -#endif - -/* API */ -VG_STATIC void vg_enter( int argc, char *argv[], const char *window_name ); - -/* Thread 1 */ -VG_STATIC void vg_preload(void); -VG_STATIC void vg_load(void); - -/* Main thread */ -VG_STATIC void vg_launch_opt(void); -VG_STATIC void vg_start(void); - -VG_STATIC void vg_framebuffer_resize(int w, int h); -VG_STATIC void vg_update(void); -VG_STATIC void vg_update_fixed(void); -VG_STATIC void vg_update_post(void); - -VG_STATIC void vg_render(void); -VG_STATIC void vg_ui(void); - #ifndef VG_HEADER_H #define VG_HEADER_H @@ -95,6 +70,31 @@ VG_STATIC void vg_ui(void); #ifndef _WIN32 #include #endif + +VG_STATIC void vg_print_backtrace(void) +{ +#ifndef _WIN32 + + void *array[20]; + char **strings; + int size, i; + + size = backtrace( array, 20 ); + strings = backtrace_symbols( array, size ); + + if( strings != NULL ){ + vg_error( "---------------- gnu backtrace -------------\n" ); + + for( int i=0; i #include -void vg_print_backtrace(void); +VG_STATIC void vg_print_backtrace(void); #define VG_MAX_ALLOCATIONS 128 #define VG_FUZZ_ALLOCATIONS @@ -337,8 +337,7 @@ VG_STATIC void *vg_create_linear_allocator( void *lin_alloc, u32 size, alloc->allocation_count ++; } - else - { + else{ if( vg_mem.use_libc_malloc && (flags & VG_MEMORY_SYSTEM) ) header = malloc( sizeof(vg_linear_allocator) ); else diff --git a/vg_platform.h b/vg_platform.h index 319f7a9..210192d 100644 --- a/vg_platform.h +++ b/vg_platform.h @@ -1,6 +1,12 @@ #ifndef VG_PLATFORM_H #define VG_PLATFORM_H +#ifdef VG_RELEASE + #define VG_STATIC static +#else + #define VG_STATIC +#endif + //#include "vg.h" #include "vg_stdint.h" @@ -29,10 +35,6 @@ struct vg_achievement const char *name; }; -#ifndef VG_STATIC -#define VG_STATIC static -#endif - #define vg_static_assert _Static_assert #define vg_list_size( A ) (sizeof(A)/sizeof(A[0])) #define VG_MUST_USE_RESULT __attribute__((warn_unused_result)) @@ -58,5 +60,4 @@ VG_STATIC void vg_strncpy( const char *src, char *dst, u32 len ) #define VG_MIN( A, B ) ((A)<(B)?(A):(B)) #define VG_MAX( A, B ) ((A)>(B)?(A):(B)) - #endif -- 2.25.1