From a3d27eedb7107d7dd964fcc9d25c6464e3280b98 Mon Sep 17 00:00:00 2001 From: TimePath Date: Tue, 8 Aug 2017 21:14:47 +1000 Subject: [PATCH] Wrap some buffers --- include/itextstream.h | 5 +++ libs/CMakeLists.txt | 1 + libs/util/CMakeLists.txt | 3 ++ libs/util/buffer.cpp | 1 + libs/util/buffer.h | 79 +++++++++++++++++++++++++++++++++++++ radiant/brushxml.h | 3 +- radiant/commands.cpp | 5 ++- radiant/eclass.cpp | 3 +- radiant/eclass_def.cpp | 5 ++- radiant/entity.cpp | 9 +++-- radiant/entityinspector.cpp | 3 +- radiant/environment.cpp | 7 ++-- radiant/error.cpp | 4 +- radiant/filetypes.cpp | 3 +- radiant/gtkdlgs.cpp | 7 ++-- radiant/main.cpp | 6 ++- radiant/mainframe.cpp | 3 +- radiant/map.cpp | 13 +++--- radiant/mru.cpp | 3 +- radiant/patch.h | 4 +- radiant/patchdialog.cpp | 4 +- radiant/qe3.cpp | 3 +- radiant/textures.cpp | 5 ++- radiant/texwindow.cpp | 9 +++-- radiant/view.cpp | 3 +- radiant/watchbsp.cpp | 7 ++-- radiant/xywindow.cpp | 7 ++-- 27 files changed, 159 insertions(+), 46 deletions(-) create mode 100644 libs/util/CMakeLists.txt create mode 100644 libs/util/buffer.cpp create mode 100644 libs/util/buffer.h diff --git a/include/itextstream.h b/include/itextstream.h index 7d69c7b5..73fd074c 100644 --- a/include/itextstream.h +++ b/include/itextstream.h @@ -26,6 +26,7 @@ /// \brief Text-stream interfaces. #include +#include #include "generic/static.h" /// \brief A read-only character-stream. @@ -65,6 +66,10 @@ inline TextOutputStream& operator<<( TextOutputStream& ostream, const T& t ){ return ostream_write( ostream, t ); } +inline TextOutputStream& ostream_write( TextOutputStream& ostream, const u::Buffer& b ){ + return ostream << b.c_str(); +} + class NullOutputStream : public TextOutputStream { public: diff --git a/libs/CMakeLists.txt b/libs/CMakeLists.txt index 03347d71..c7e01f93 100644 --- a/libs/CMakeLists.txt +++ b/libs/CMakeLists.txt @@ -22,6 +22,7 @@ add_subdirectory(splines) add_subdirectory(stream) add_subdirectory(string) add_subdirectory(uilib) +add_subdirectory(util) add_subdirectory(xml) add_library(libs diff --git a/libs/util/CMakeLists.txt b/libs/util/CMakeLists.txt new file mode 100644 index 00000000..7a89b6e3 --- /dev/null +++ b/libs/util/CMakeLists.txt @@ -0,0 +1,3 @@ +add_library(util + buffer.cpp + ) diff --git a/libs/util/buffer.cpp b/libs/util/buffer.cpp new file mode 100644 index 00000000..113a8001 --- /dev/null +++ b/libs/util/buffer.cpp @@ -0,0 +1 @@ +#include "buffer.h" diff --git a/libs/util/buffer.h b/libs/util/buffer.h new file mode 100644 index 00000000..9ce31d62 --- /dev/null +++ b/libs/util/buffer.h @@ -0,0 +1,79 @@ +#ifndef INCLUDED_BUFFER_H +#define INCLUDED_BUFFER_H + +namespace u { + + using byte = char; + + using cstring = const char *; + + namespace details { + struct Reference { + private: + int m_size; + byte *m_data; + public: + Reference(int m_size, byte *m_data) + : m_size(m_size), m_data(m_data) {} + + int size() const { + return m_size; + } + + const byte *data() const { + return m_data; + } + + byte *data() { + return m_data; + } + }; + + template + struct Value { + byte m_data[sz]; + + int size() const { + return sz; + } + + const byte *data() const { + return m_data; + } + + byte *data() { + return m_data; + } + }; + } + + template + class IBuffer : Self { + using Self::Self; + public: + operator const IBuffer() const { + return IBuffer{this->size(), const_cast(this->data())}; + } + + cstring c_str() const { + return this->data(); + } + + operator byte *() { + return this->data(); + } + }; + + template + using BufferVal = IBuffer>; + + using Buffer = IBuffer; + + template + BufferVal buffer() { + return BufferVal(); + } + +} + +#endif diff --git a/radiant/brushxml.h b/radiant/brushxml.h index c1fac55b..d312591c 100644 --- a/radiant/brushxml.h +++ b/radiant/brushxml.h @@ -22,6 +22,7 @@ #if !defined( INCLUDED_BRUSHXML_H ) #define INCLUDED_BRUSHXML_H +#include #include "stream/stringstream.h" #include "xml/xmlelement.h" @@ -233,7 +234,7 @@ inline void FacePlane_exportXML( const FacePlane& facePlane, XMLImporter& import inline void FacePolygon_exportXML( const Winding& w, const BasicVector3& normal, XMLImporter& importer ){ DynamicElement element( "polygon" ); - char tmp[32]; + auto tmp = u::buffer<32>(); sprintf( tmp, "%f", normal.x() ); element.insertAttribute( "nx", tmp ); diff --git a/radiant/commands.cpp b/radiant/commands.cpp index cf9c68ce..06dc7575 100644 --- a/radiant/commands.cpp +++ b/radiant/commands.cpp @@ -150,6 +150,7 @@ void connect_accelerator( const char *name ){ #include #include +#include #include "gtkutil/dialog.h" #include "mainframe.h" @@ -537,7 +538,7 @@ public: ReadCommandMap( const char* filename ) : m_filename( filename ), m_count( 0 ){ } void visit( const char* name, Accelerator& accelerator ){ - char value[1024]; + auto value = u::buffer<1024>(); if ( read_var( m_filename, "Commands", name, value ) ) { if ( string_empty( value ) ) { accelerator.key = 0; @@ -575,7 +576,7 @@ void LoadCommandMap( const char* path ){ Version dataVersion = { 0, 0 }; { - char value[1024]; + auto value = u::buffer<1024>(); if ( read_var( strINI.c_str(), "Version", "number", value ) ) { dataVersion = version_parse( value ); } diff --git a/radiant/eclass.cpp b/radiant/eclass.cpp index ea9828e5..892a2dde 100644 --- a/radiant/eclass.cpp +++ b/radiant/eclass.cpp @@ -24,6 +24,7 @@ #include "debugging/debugging.h" #include +#include #include "ifilesystem.h" @@ -45,7 +46,7 @@ namespace typedef std::map EntityClasses; EntityClasses g_entityClasses; EntityClass *eclass_bad = 0; -char eclass_directory[1024]; +u::BufferVal<1024> eclass_directory; typedef std::map ListAttributeTypes; ListAttributeTypes g_listTypes; } diff --git a/radiant/eclass_def.cpp b/radiant/eclass_def.cpp index 8637b480..a619ed74 100644 --- a/radiant/eclass_def.cpp +++ b/radiant/eclass_def.cpp @@ -30,6 +30,7 @@ #include "stream/textfilestream.h" #include "modulesystem/moduleregistry.h" #include "os/path.h" +#include const char* EClass_GetExtension(){ return "def"; @@ -69,7 +70,7 @@ StaticRegisterModule staticRegisterEclassDef( StaticEclassDefModule::instance() #include -char com_token[1024]; +u::BufferVal<1024> com_token; bool com_eof; /* @@ -248,7 +249,7 @@ EntityClass *Eclass_InitFromText( const char *text ){ } } - char parms[256]; + auto parms = u::buffer<256>(); // get the flags { // copy to the first /n diff --git a/radiant/entity.cpp b/radiant/entity.cpp index cf726aca..87cf9cd0 100644 --- a/radiant/entity.cpp +++ b/radiant/entity.cpp @@ -19,6 +19,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include #include "entity.h" #include "ientity.h" @@ -354,7 +355,7 @@ void Entity_createFromSelection( const char* name, const Vector3& origin ){ if ( DoLightIntensityDlg( &intensity ) == eIDOK ) { g_iLastLightIntensity = intensity; - char buf[30]; + auto buf = u::buffer<30>(); sprintf( buf, "255 255 255 %d", intensity ); Node_getEntity( node )->setKeyValue( "_light", buf ); } @@ -366,7 +367,7 @@ void Entity_createFromSelection( const char* name, const Vector3& origin ){ if ( DoLightIntensityDlg( &intensity ) == eIDOK ) { g_iLastLightIntensity = intensity; - char buf[10]; + auto buf = u::buffer<10>(); sprintf( buf, "%d", intensity ); Node_getEntity( node )->setKeyValue( "light", buf ); } @@ -472,7 +473,7 @@ void Entity_normalizeColor(){ g_entity_globals.color_entity = rgb; NormalizeColor( g_entity_globals.color_entity ); - char buffer[128]; + auto buffer = u::buffer<128>(); sprintf( buffer, "%g %g %g", g_entity_globals.color_entity[0], g_entity_globals.color_entity[1], g_entity_globals.color_entity[2] ); @@ -508,7 +509,7 @@ void Entity_setColour(){ NormalizeColor( g_entity_globals.color_entity ); } - char buffer[128]; + auto buffer = u::buffer<128>(); sprintf( buffer, "%g %g %g", g_entity_globals.color_entity[0], g_entity_globals.color_entity[1], g_entity_globals.color_entity[2] ); diff --git a/radiant/entityinspector.cpp b/radiant/entityinspector.cpp index ff567060..1e6b5d06 100644 --- a/radiant/entityinspector.cpp +++ b/radiant/entityinspector.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include "os/path.h" @@ -1005,7 +1006,7 @@ void EntityInspector_updateSpawnflags(){ void EntityInspector_applySpawnflags(){ int f, i, v; - char sz[32]; + auto sz = u::buffer<32>(); f = 0; for ( i = 0; i < g_spawnflag_count; ++i ) diff --git a/radiant/environment.cpp b/radiant/environment.cpp index a91b109b..0d5c243a 100644 --- a/radiant/environment.cpp +++ b/radiant/environment.cpp @@ -19,6 +19,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include #include "environment.h" #include "stream/textstream.h" @@ -57,7 +58,7 @@ void args_init( int argc, const char* argv[] ){ const char *gamedetect_argv_buffer[1024]; void gamedetect_found_game( const char *game, char *path ){ int argc; - static char buf[128]; + static auto buf = u::buffer<128>(); if ( g_argv == gamedetect_argv_buffer ) { return; @@ -114,7 +115,7 @@ void gamedetect(){ ++i; } if ( !nogamedetect ) { - static char buf[1024 + 64]; + static auto buf = u::buffer<1024 + 64>(); strncpy( buf, environment_get_app_path(), sizeof( buf ) ); buf[sizeof( buf ) - 1 - 64] = 0; if ( !strlen( buf ) ) { @@ -261,7 +262,7 @@ void environment_init( int argc, const char* argv[] ){ { // get path to the editor - char filename[MAX_PATH + 1]; + auto filename = u::buffer(); GetModuleFileName( 0, filename, MAX_PATH ); char* last_separator = strrchr( filename, '\\' ); if ( last_separator != 0 ) { diff --git a/radiant/error.cpp b/radiant/error.cpp index fda7f79f..56a8a056 100644 --- a/radiant/error.cpp +++ b/radiant/error.cpp @@ -35,6 +35,8 @@ #else #include #include +#include + #endif @@ -55,7 +57,7 @@ void Error( const char *error, ... ){ va_list argptr; - char text[4096]; + auto text = u::buffer<4096>(); va_start( argptr,error ); vsprintf( text, error,argptr ); diff --git a/radiant/filetypes.cpp b/radiant/filetypes.cpp index 6a08cecd..115b1e26 100644 --- a/radiant/filetypes.cpp +++ b/radiant/filetypes.cpp @@ -29,6 +29,7 @@ #include "os/path.h" #include #include +#include class RadiantFileTypeRegistry : public IFileTypeRegistry { @@ -87,7 +88,7 @@ IFileTypeRegistry* GetFileTypeRegistry(){ const char* findModuleName( IFileTypeRegistry* registry, const char* moduleType, const char* extension ){ class SearchFileTypeList : public IFileTypeList { - char m_pattern[128]; + u::BufferVal<128> m_pattern; const char* m_moduleName; public: SearchFileTypeList( const char* ext ) diff --git a/radiant/gtkdlgs.cpp b/radiant/gtkdlgs.cpp index fe547435..3486c1ba 100644 --- a/radiant/gtkdlgs.cpp +++ b/radiant/gtkdlgs.cpp @@ -48,6 +48,7 @@ #include #include +#include #include "os/path.h" #include "math/aabb.h" @@ -675,8 +676,8 @@ EMessageBoxReturn DoTextureLayout( float *fx, float *fy ){ } // Initialize with last used values - char buf[16]; - + auto buf = u::buffer<16>(); + sprintf( buf, "%f", last_used_texture_layout_scale_x ); x.text( buf ); @@ -899,7 +900,7 @@ EMessageBoxReturn DoLightIntensityDlg( int *intensity ){ } } - char buf[16]; + auto buf = u::buffer<16>(); sprintf( buf, "%d", *intensity ); intensity_entry.text(buf); diff --git a/radiant/main.cpp b/radiant/main.cpp index 74ddce1f..270e8a5a 100644 --- a/radiant/main.cpp +++ b/radiant/main.cpp @@ -89,6 +89,8 @@ #include "referencecache.h" #include "stacktrace.h" +#include + #ifdef WIN32 #include #endif @@ -99,7 +101,7 @@ void hide_splash(); void error_redirect( const gchar *domain, GLogLevelFlags log_level, const gchar *message, gpointer user_data ){ gboolean in_recursion; gboolean is_fatal; - char buf[256]; + auto buf = u::buffer<256>(); in_recursion = ( log_level & G_LOG_FLAG_RECURSION ) != 0; is_fatal = ( log_level & G_LOG_FLAG_FATAL ) != 0; @@ -347,7 +349,7 @@ void paths_init(){ bool check_version_file( const char* filename, const char* version ){ TextFileInputStream file( filename ); if ( !file.failed() ) { - char buf[10]; + auto buf = u::buffer<10>(); buf[file.read( buf, 9 )] = '\0'; // chomp it (the hard way) diff --git a/radiant/mainframe.cpp b/radiant/mainframe.cpp index b54ff827..02c8c9b3 100644 --- a/radiant/mainframe.cpp +++ b/radiant/mainframe.cpp @@ -40,6 +40,7 @@ #include #include +#include #include "cmdlib.h" @@ -527,7 +528,7 @@ public: CLoadModule( const char* path ) : m_path( path ){ } void operator()( const char* name ) const { - char fullname[1024]; + auto fullname = u::buffer<1024>(); ASSERT_MESSAGE( strlen( m_path ) + strlen( name ) < 1024, "" ); strcpy( fullname, m_path ); strcat( fullname, name ); diff --git a/radiant/map.cpp b/radiant/map.cpp index 33dcebe9..2f42496f 100644 --- a/radiant/map.cpp +++ b/radiant/map.cpp @@ -45,6 +45,7 @@ MapModules& ReferenceAPI_getMapModules(); #include #include +#include #include "uilib/uilib.h" #include "scenelib.h" @@ -151,7 +152,7 @@ void detach( const NameCallback& setName, const NameCallbackCallback& detachObse } void makeUnique( const char* name, const NameCallback& setName ) const { - char buffer[1024]; + auto buffer = u::buffer<1024>(); name_write( buffer, m_uniqueNames.make_unique( name_read( name ) ) ); setName( buffer ); } @@ -173,7 +174,7 @@ void mergeNames( const BasicNamespace& other ) const { name_t uniqueName( uniqueNames.make_unique( name_read( ( *i ).first.c_str() ) ) ); uniqueNames.insert( uniqueName ); - char buffer[1024]; + auto buffer = u::buffer<1024>(); name_write( buffer, uniqueName ); //globalOutputStream() << "renaming " << makeQuoted((*i).first.c_str()) << " to " << makeQuoted(buffer) << "\n"; @@ -877,7 +878,7 @@ void DoMapInfo(){ for ( EntityBreakdown::iterator i = entitymap.begin(); i != entitymap.end(); ++i ) { - char tmp[16]; + auto tmp = u::buffer<16>(); sprintf( tmp, "%u", Unsigned( ( *i ).second ) ); GtkTreeIter iter; gtk_list_store_append( GTK_LIST_STORE( EntityBreakdownWalker ), &iter ); @@ -887,7 +888,7 @@ void DoMapInfo(){ EntityBreakdownWalker.unref(); - char tmp[16]; + auto tmp = u::buffer<16>(); sprintf( tmp, "%u", Unsigned( g_brushCount.get() ) ); brushes_entry.text(tmp); sprintf( tmp, "%u", Unsigned( g_entityCount.get() ) ); @@ -1267,7 +1268,7 @@ void ConstructRegionStartpoint( scene::Node* startpoint, const Vector3& region_m } // write the info_playerstart - char sTmp[1024]; + auto sTmp = u::buffer<1024>(); sprintf( sTmp, "%d %d %d", (int)vOrig[0], (int)vOrig[1], (int)vOrig[2] ); Node_getEntity( *startpoint )->setKeyValue( "origin", sTmp ); sprintf( sTmp, "%d", (int)Camera_getAngles( *g_pParentWnd->GetCamWnd() )[CAMERA_YAW] ); @@ -2101,7 +2102,7 @@ void DoFind(){ } // Initialize dialog - char buf[16]; + auto buf = u::buffer<16>(); int ent, br; GetSelectionIndex( &ent, &br ); diff --git a/radiant/mru.cpp b/radiant/mru.cpp index 3a01d142..916ea842 100644 --- a/radiant/mru.cpp +++ b/radiant/mru.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include "os/file.h" #include "generic/callback.h" @@ -142,7 +143,7 @@ void MRU_AddWidget( GtkMenuItem *widget, std::size_t pos ){ } void MRU_Activate( std::size_t index ){ - char text[1024]; + auto text = u::buffer<1024>(); strcpy( text, MRU_GetText( index ) ); if ( file_readable( text ) ) { //\todo Test 'map load succeeds' instead of 'file is readable'. diff --git a/radiant/patch.h b/radiant/patch.h index a1f1d272..bc98fabe 100644 --- a/radiant/patch.h +++ b/radiant/patch.h @@ -44,6 +44,7 @@ #include #include +#include #include "math/frustum.h" #include "string/string.h" @@ -803,7 +804,8 @@ void exportXML( XMLImporter& importer ){ } { - char width[16], height[16]; + auto width = u::buffer<16>(); + auto height = u::buffer<16>(); sprintf( width, "%u", Unsigned( m_width ) ); sprintf( height, "%u", Unsigned( m_height ) ); StaticElement element( "matrix" ); diff --git a/radiant/patchdialog.cpp b/radiant/patchdialog.cpp index da5e2283..7c1e63a4 100644 --- a/radiant/patchdialog.cpp +++ b/radiant/patchdialog.cpp @@ -1079,7 +1079,7 @@ void PatchInspector::GetPatchInfo(){ m_countRows = m_Patch->getHeight(); for ( std::size_t i = 0; i < m_countRows; ++i ) { - char buffer[16]; + auto buffer = u::buffer<16>(); sprintf( buffer, "%u", Unsigned( i ) ); gtk_combo_box_text_append_text( m_pRowCombo, buffer ); } @@ -1098,7 +1098,7 @@ void PatchInspector::GetPatchInfo(){ m_countCols = m_Patch->getWidth(); for ( std::size_t i = 0; i < m_countCols; ++i ) { - char buffer[16]; + auto buffer = u::buffer<16>(); sprintf( buffer, "%u", Unsigned( i ) ); gtk_combo_box_text_append_text( m_pColCombo, buffer ); } diff --git a/radiant/qe3.cpp b/radiant/qe3.cpp index 7d685bae..717c3c84 100644 --- a/radiant/qe3.cpp +++ b/radiant/qe3.cpp @@ -44,6 +44,7 @@ #include #include +#include #include "stream/textfilestream.h" #include "cmdlib.h" @@ -118,7 +119,7 @@ int g_numbrushes = 0; int g_numentities = 0; void QE_UpdateStatusBar(){ - char buffer[128]; + auto buffer = u::buffer<128>(); sprintf( buffer, "Brushes: %d Entities: %d", g_numbrushes, g_numentities ); g_pParentWnd->SetStatusText( g_pParentWnd->m_brushcount_status, buffer ); } diff --git a/radiant/textures.cpp b/radiant/textures.cpp index 93ce42a8..3b96fbbf 100644 --- a/radiant/textures.cpp +++ b/radiant/textures.cpp @@ -19,6 +19,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include #include "textures.h" #include "debugging/debugging.h" @@ -137,7 +138,7 @@ ETexturesMode g_texture_mode = eTextures_LINEAR_MIPMAP_LINEAR; -byte g_gammatable[256]; +u::BufferVal<256> g_gammatable; void ResampleGamma( float fGamma ){ int i,inf; if ( fGamma == 1.0 ) { @@ -274,7 +275,7 @@ void Texture_InitPalette( byte *pal ){ int r,g,b; int i; int inf; - byte gammatable[256]; + auto gammatable = u::buffer<256>(); float gamma; gamma = g_texture_globals.fGamma; diff --git a/radiant/texwindow.cpp b/radiant/texwindow.cpp index 03b141ae..0f25c594 100644 --- a/radiant/texwindow.cpp +++ b/radiant/texwindow.cpp @@ -43,6 +43,7 @@ #include #include +#include #include "signal/signal.h" #include "math/vector.h" @@ -1567,7 +1568,7 @@ void TreeView_onRowActivated( GtkTreeView* treeview, GtkTreePath* path, GtkTreeV GtkTreeModel* model = gtk_tree_view_get_model( GTK_TREE_VIEW( treeview ) ); if ( gtk_tree_model_get_iter( model, &iter, path ) ) { - gchar dirName[1024]; + auto dirName = u::buffer<1024>(); gchar* buffer; gtk_tree_model_get( model, &iter, 0, &buffer, -1 ); @@ -1848,8 +1849,8 @@ void TextureBrowser_searchTags(){ GSList* selected = NULL; GSList* node; gchar* tag; - char buffer[256]; - char tags_searched[256]; + auto buffer = u::buffer<256>(); + auto tags_searched = u::buffer<256>(); GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( g_TextureBrowser.m_treeViewTags ) ); @@ -2424,7 +2425,7 @@ void TextureBrowser_RefreshShaders(){ GtkTreeIter iter; if ( gtk_tree_selection_get_selected (selection, &model, &iter) ) { - gchar dirName[1024]; + auto dirName = u::buffer<1024>(); gchar* buffer; gtk_tree_model_get( model, &iter, 0, &buffer, -1 ); diff --git a/radiant/view.cpp b/radiant/view.cpp index a0a48c43..38b50538 100644 --- a/radiant/view.cpp +++ b/radiant/view.cpp @@ -24,8 +24,9 @@ #if defined( DEBUG_CULLING ) #include +#include -char g_cull_stats[1024]; +u::BufferVal<1024> g_cull_stats; int g_count_dots; int g_count_planes; int g_count_oriented_planes; diff --git a/radiant/watchbsp.cpp b/radiant/watchbsp.cpp index 4824d23e..6ac7f553 100644 --- a/radiant/watchbsp.cpp +++ b/radiant/watchbsp.cpp @@ -77,6 +77,7 @@ void message_print( message_info_t* self, const char* characters, std::size_t le #include #include +#include #include "xmlstuff.h" class CWatchBSP @@ -400,7 +401,7 @@ static void saxComment( void *ctx, const xmlChar *msg ){ } static void saxWarning( void *ctx, const char *msg, ... ){ - char saxMsgBuffer[4096]; + auto saxMsgBuffer = u::buffer<4096>(); va_list args; va_start( args, msg ); @@ -410,7 +411,7 @@ static void saxWarning( void *ctx, const char *msg, ... ){ } static void saxError( void *ctx, const char *msg, ... ){ - char saxMsgBuffer[4096]; + auto saxMsgBuffer = u::buffer<4096>(); va_list args; va_start( args, msg ); @@ -420,7 +421,7 @@ static void saxError( void *ctx, const char *msg, ... ){ } static void saxFatal( void *ctx, const char *msg, ... ){ - char buffer[4096]; + auto buffer = u::buffer<4096>(); va_list args; diff --git a/radiant/xywindow.cpp b/radiant/xywindow.cpp index 61a7a021..4e6b531e 100644 --- a/radiant/xywindow.cpp +++ b/radiant/xywindow.cpp @@ -43,6 +43,7 @@ #include #include +#include #include "generic/callback.h" #include "string/string.h" @@ -1437,7 +1438,7 @@ void XYWnd::XY_LoadBackgroundImage( const char *name ){ globalOutputStream() << "WARNING: could not extract the relative path, using full path instead\n"; } - char fileNameWithoutExt[512]; + auto fileNameWithoutExt = u::buffer<512>(); strncpy( fileNameWithoutExt, relative, sizeof( fileNameWithoutExt ) - 1 ); fileNameWithoutExt[512 - 1] = '\0'; fileNameWithoutExt[strlen( fileNameWithoutExt ) - 4] = '\0'; @@ -1596,7 +1597,7 @@ void XYWnd::XY_DrawBackground( void ){ void XYWnd::XY_DrawGrid( void ) { float x, y, xb, xe, yb, ye; float w, h, a; - char text[32]; + auto text = u::buffer<32>(); float step, minor_step, stepx, stepy; step = minor_step = stepx = stepy = GetGridSize(); @@ -1778,7 +1779,7 @@ void XYWnd::XY_DrawBlockGrid(){ float x, y, xb, xe, yb, ye; float w, h; - char text[32]; + auto text = u::buffer<32>(); glDisable( GL_TEXTURE_2D ); glDisable( GL_TEXTURE_1D ); -- 2.39.2