medfall

A super great game engine
Log | Files | Refs

commit edee6769e92124056ef1ce2ecb813e1f13527220
parent bf0b68013bc4c2ade559678555daba81620e2979
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Sat May 27 22:44:26 +0300

ggformat for array< const char >

Diffstat:
array.h | 9+++++++++
1 file changed, 9 insertions(+), 0 deletions(-)
diff --git a/array.h b/array.h @@ -3,6 +3,7 @@ #include <stdlib.h> #include "intrinsics.h" +#include "ggformat.h" #include "log.h" template< typename T > @@ -407,3 +408,11 @@ template< typename T > static T bilerp01( const array2d< T > arr, float x, float y ) { return bilerp( arr, x * arr.w, y * arr.h ); } + +inline void format( FormatBuffer * fb, array< const char > arr, const FormatOpts & opts ) { + if( fb->len < fb->capacity ) { + size_t len = min( arr.n + 1, fb->capacity - fb->len ); + strlcpy( fb->buf + fb->len, arr.ptr(), len ); + } + fb->len += arr.n; +}