5 #define VG_STATIC static
11 #include "vg_stdint.h"
13 /* Copyright (C) 2021-2022 Harry Godden (hgn) - All Rights Reserved */
15 typedef unsigned int uint
;
30 typedef struct vg_tex2d vg_tex2d
;
38 #define vg_static_assert _Static_assert
39 #define vg_list_size( A ) (sizeof(A)/sizeof(A[0]))
40 #define VG_MUST_USE_RESULT __attribute__((warn_unused_result))
42 enum strncpy_behaviour
{
43 k_strncpy_always_add_null
= 0,
44 k_strncpy_allow_cutoff
= 1
47 VG_STATIC u32
vg_strncpy( const char *src
, char *dst
, u32 len
,
48 enum strncpy_behaviour behaviour
)
50 for( u32 i
=0; i
<len
; i
++ ){
53 if( !src
[i
] ) return i
;
55 if( (behaviour
== k_strncpy_always_add_null
) && (i
== len
-1) ){
64 VG_STATIC u32
vg_strdjb2( const char *str
)
69 hash
= ((hash
<< 5) + hash
) + c
; /* hash * 33 + c */
82 #define VG_MIN( A, B ) ((A)<(B)?(A):(B))
83 #define VG_MAX( A, B ) ((A)>(B)?(A):(B))