summaryrefslogtreecommitdiff
path: root/src/util/config/config.cpp
diff options
context:
space:
mode:
authoraura <nw@moneybot.cc>2026-03-16 10:15:01 +0100
committeraura <nw@moneybot.cc>2026-03-16 10:15:01 +0100
commitfdc5e8760fb7ac0af8e7ebb98a2076db15e31082 (patch)
treec94991e1e594c7703295aa413caf40786f343c1f /src/util/config/config.cpp
parente2829336cfedb39d23263f75b61ed969c8193534 (diff)
giga refactor, fix ALL the leaks
Diffstat (limited to 'src/util/config/config.cpp')
-rw-r--r--src/util/config/config.cpp13
1 files changed, 3 insertions, 10 deletions
diff --git a/src/util/config/config.cpp b/src/util/config/config.cpp
index a41e455..00a2512 100644
--- a/src/util/config/config.cpp
+++ b/src/util/config/config.cpp
@@ -30,9 +30,7 @@ inline void trim_whitespace( char* buf ) {
}
inline void init_cfg_node( CFG_NODE* node, const char* name, CFG_NODE* parent, U8 type ) {
- memset( node->name, 0, sizeof(node->name) );
- strcpy( node->name, name );
- node->name[sizeof(node->name) - 1] = '\0';
+ node->name = name;
node->parent = parent;
if( parent )
( (CFG_SECTION*)parent )->children.push( node );
@@ -290,17 +288,12 @@ STAT cfg_save( CFG_SECTION* root, const char* path ) {
if( !f )
return STAT_ERR;
- char* buf = (char*)malloc( 999999 );
- buf[0] = 0;
CFG_SERIALIZER s;
s.tabc = 0;
s.f = f;
- cfg_serialize_section( &s, (CFG_NODE*)root, buf );
- U32 len = strlen( buf );
-
- fwrite( buf, 1, len, f );
- free( buf );
+ STR buf = cfg_serialize_section( &s, (CFG_NODE*)root );
+ fwrite( buf, 1, buf.size, f );
fclose( f );
return STAT_OK;