@@ -138,7 +138,7 @@ static int systemd_enumerate_data_store(struct flb_config *config,
138138 const char * sep ;
139139 const char * key ;
140140 const char * val ;
141- char * buf = NULL ;
141+ char * buf ;
142142 struct cfl_kvlist * kvlist = format_context ;
143143 struct flb_systemd_config * ctx = plugin_context ;
144144 struct cfl_variant * cfl_val = NULL ;
@@ -155,31 +155,19 @@ static int systemd_enumerate_data_store(struct flb_config *config,
155155
156156 len = (sep - key );
157157 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 );
178159
179160 if (!list_key ) {
180161 return -1 ;
181162 }
182163
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+
183171 /* Check existence */
184172 cfl_val = NULL ;
185173 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,
274262 uint64_t usec ;
275263 size_t length ;
276264 const char * key ;
277- char * buf = NULL ;
278265#ifdef FLB_HAVE_SQLDB
279266 char * cursor = NULL ;
280267#endif
@@ -458,8 +445,6 @@ static int in_systemd_collect(struct flb_input_instance *ins,
458445 }
459446 }
460447
461- flb_sds_destroy (buf );
462-
463448#ifdef FLB_HAVE_SQLDB
464449 /* Save cursor */
465450 if (ctx -> db ) {
0 commit comments