@@ -138,7 +138,7 @@ static int systemd_enumerate_data_store(struct flb_config *config,
138
138
const char * sep ;
139
139
const char * key ;
140
140
const char * val ;
141
- char * buf = NULL ;
141
+ char * buf ;
142
142
struct cfl_kvlist * kvlist = format_context ;
143
143
struct flb_systemd_config * ctx = plugin_context ;
144
144
struct cfl_variant * cfl_val = NULL ;
@@ -155,31 +155,19 @@ static int systemd_enumerate_data_store(struct flb_config *config,
155
155
156
156
len = (sep - key );
157
157
key_len = len ;
158
-
159
- if (ctx -> lowercase == FLB_TRUE ) {
160
- /*
161
- * Ensure buf to have enough space for the key because the libsystemd
162
- * might return larger data than the threshold.
163
- */
164
- if (buf == NULL ) {
165
- buf = flb_sds_create_len (NULL , ctx -> threshold );
166
- }
167
- if (flb_sds_alloc (buf ) < len ) {
168
- buf = flb_sds_increase (buf , len - flb_sds_alloc (buf ));
169
- }
170
- for (i = 0 ; i < len ; i ++ ) {
171
- buf [i ] = tolower (key [i ]);
172
- }
173
- list_key = flb_sds_create_len (buf , key_len );
174
- }
175
- else {
176
- list_key = flb_sds_create_len (key , key_len );
177
- }
158
+ list_key = flb_sds_create_len (key , key_len );
178
159
179
160
if (!list_key ) {
180
161
return -1 ;
181
162
}
182
163
164
+ if (ctx -> lowercase == FLB_TRUE ) {
165
+ buf = list_key ;
166
+ for (i = 0 ; i < key_len ; i ++ ) {
167
+ buf [i ] = tolower (buf [i ]);
168
+ }
169
+ }
170
+
183
171
/* Check existence */
184
172
cfl_val = NULL ;
185
173
cfl_val = cfl_kvlist_fetch_s (kvlist , list_key , key_len );
@@ -274,7 +262,6 @@ static int in_systemd_collect(struct flb_input_instance *ins,
274
262
uint64_t usec ;
275
263
size_t length ;
276
264
const char * key ;
277
- char * buf = NULL ;
278
265
#ifdef FLB_HAVE_SQLDB
279
266
char * cursor = NULL ;
280
267
#endif
@@ -458,8 +445,6 @@ static int in_systemd_collect(struct flb_input_instance *ins,
458
445
}
459
446
}
460
447
461
- flb_sds_destroy (buf );
462
-
463
448
#ifdef FLB_HAVE_SQLDB
464
449
/* Save cursor */
465
450
if (ctx -> db ) {
0 commit comments