mirror of
https://github.com/CTCaer/hekate.git
synced 2024-11-22 18:06:40 +00:00
bdk: ini: simplify kv free
This commit is contained in:
parent
e5ddac5211
commit
2378bf2863
1 changed files with 7 additions and 9 deletions
|
@ -189,29 +189,27 @@ char *ini_check_payload_section(ini_sec_t *cfg)
|
||||||
|
|
||||||
void ini_free(link_t *src)
|
void ini_free(link_t *src)
|
||||||
{
|
{
|
||||||
ini_kv_t *prec_kv = NULL;
|
|
||||||
ini_sec_t *prev_sec = NULL;
|
ini_sec_t *prev_sec = NULL;
|
||||||
|
|
||||||
// Parse and free all ini sections.
|
// Parse and free all ini sections.
|
||||||
LIST_FOREACH_ENTRY(ini_sec_t, ini_sec, src, link)
|
LIST_FOREACH_ENTRY(ini_sec_t, ini_sec, src, link)
|
||||||
{
|
{
|
||||||
|
ini_kv_t *prev_kv = NULL;
|
||||||
|
|
||||||
// Free all ini key allocations if they exist.
|
// Free all ini key allocations if they exist.
|
||||||
LIST_FOREACH_ENTRY(ini_kv_t, kv, &ini_sec->kvs, link)
|
LIST_FOREACH_ENTRY(ini_kv_t, kv, &ini_sec->kvs, link)
|
||||||
{
|
{
|
||||||
// Free previous key.
|
// Free previous key.
|
||||||
if (prec_kv)
|
if (prev_kv)
|
||||||
free(prec_kv);
|
free(prev_kv);
|
||||||
|
|
||||||
// Set next key to free.
|
// Set next key to free.
|
||||||
prec_kv = kv;
|
prev_kv = kv;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Free last key.
|
// Free last key.
|
||||||
if (prec_kv)
|
if (prev_kv)
|
||||||
{
|
free(prev_kv);
|
||||||
free(prec_kv);
|
|
||||||
prec_kv = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Free previous section.
|
// Free previous section.
|
||||||
if (prev_sec)
|
if (prev_sec)
|
||||||
|
|
Loading…
Reference in a new issue