File tree 4 files changed +50
-0
lines changed
4 files changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ endmacro (do_benchmark)
33
33
do_benchmark (large)
34
34
do_benchmark (cmp)
35
35
do_benchmark (createkeys)
36
+ do_benchmark (memoryleak)
36
37
37
38
# exclude storage and KDB benchmark from mingw
38
39
if (NOT WIN32 )
Original file line number Diff line number Diff line change
1
+ /**
2
+ * @file
3
+ *
4
+ * @brief Benchmark for KDB
5
+ *
6
+ * @copyright BSD License (see LICENSE.md or https://www.libelektra.org)
7
+ */
8
+
9
+ #include <stdio.h>
10
+
11
+ #include <benchmarks.h>
12
+ #include <kdb.h>
13
+ #include <unistd.h>
14
+
15
+ #define NUM_RUNS 30
16
+
17
+ int main (void )
18
+ {
19
+ KDB * handles [NUM_RUNS ];
20
+ KeySet * keysets [NUM_RUNS ];
21
+
22
+ Key * parentKey = keyNew ("user" , KEY_END );
23
+
24
+ for (size_t i = 0 ; i < NUM_RUNS ; ++ i )
25
+ {
26
+ KDB * handle = kdbOpen (parentKey );
27
+
28
+ KeySet * ks = ksNew (0 , KS_END );
29
+
30
+ kdbGet (handle , ks , parentKey );
31
+
32
+ printf ("Retrieved %d keys\n" , (int ) ksGetSize (ks ));
33
+
34
+ handles [i ] = handle ;
35
+ keysets [i ] = ks ;
36
+ }
37
+
38
+ for (size_t i = 0 ; i < NUM_RUNS ; ++ i )
39
+ {
40
+ printf ("Freeing %d keys\n" , (int ) ksGetSize (keysets [i ]));
41
+
42
+ kdbClose (handles [i ], parentKey );
43
+ ksDel (keysets [i ]);
44
+ }
45
+
46
+ keyDel (parentKey );
47
+ }
Original file line number Diff line number Diff line change @@ -153,6 +153,7 @@ The text below summarizes updates to the [C (and C++)-based libraries](https://w
153
153
- ` kdbconfig.h ` is no longer included in the installed headers. This is because it could cause conflicts with other
154
154
` config.h ` -type headers from applications. _ (Klemens Böswirth)_
155
155
- ` ksAppendKey ` : state that it only fail on memory problems. _ (Markus Raab)_
156
+ - Fix memory leak in ` kdbGet ` . _ (Markus Raab)_
156
157
- Implemented ` kdberrors.h ` directly without generation of the ` specification ` file because of drastically reduced error code count _ (Michael Zronek)_
157
158
- ` keyIsDirectBelow ` was renamed to ` keyIsDirectlyBelow ` . _ (Philipp Gackstatter)_
158
159
- ` keyMeta ` was added to provide access to a key's underlying KeySet that holds its metadata keys. _ (Philipp Gackstatter)_
Original file line number Diff line number Diff line change @@ -333,6 +333,7 @@ KDB * kdbOpen (Key * errorKey)
333
333
keySetString (errorKey , keyString (initialParent ));
334
334
keyDel (initialParent );
335
335
errno = errnosave ;
336
+ ksDel (keys );
336
337
return 0 ;
337
338
case 0 :
338
339
ELEKTRA_ADD_INSTALLATION_WARNING (errorKey , "Initial 'kdbGet()' failed, you should either fix " KDB_DB_INIT
You can’t perform that action at this time.
0 commit comments