confuse-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Confuse-devel] Deleting a section...


From: Sergey Katsev
Subject: [Confuse-devel] Deleting a section...
Date: Tue, 31 Aug 2010 16:55:18 -0400

I'm trying to programmatically delete a section.  Here's some background:

> Hi,
> 
> Is there any supported way of deleting a section?
> 
> For example, if I have a configuration file that has:
> 
> thing name1 {
>       parameter1 = "abc"
>       parameter2 = "efg"
> }
> 
> thing name2 {
>       parameter1 = "efc"
>       parameter2 = "foo"
> }
> 
> I want to be able to:
> 
> 1) parse the file 
> 2) loop through all of the "things", find the one called "name2"
> 3) delete it so it's completely gone
> 4) write the result back to the file
> 
> I don't see any way to do #3.  cfg_free, which seems to be what I would want 
> ends up trashing memory if you try to write this configuration file back out, 
> and cfg_free_value just clears the values rather than deleting the whole 
> thing.
> 
> Any ideas on where to look?
> 

Martin replied and said this isn't currently supported so I'm looking for a way 
to implement it.

What I'm trying right now is using cfg_free() on opt->values[i]->section, and 
then decrement opt->nvalues.  

However, it looks like although it "works", it corrupts memory so the next time 
I try to use the in-memory parsed data, I get core dumps.  Is there something 
else that I'm not cleaning up that I should be?

Thanks in advance.

Sergey


reply via email to

[Prev in Thread] Current Thread [Next in Thread]