Anope IRC Services

Anope.org => Anope General => Topic started by: Jan Milants on March 28, 2007, 01:39:57 PM

Title: Using moduledata to store structs...
Post by: Jan Milants on March 28, 2007, 01:39:57 PM
I use the ModuleData space provided in the User and ChannelInfo struct to store references to a list of structs in parsed to a char. I use a modified version of the moduleAddData to prevent it from sstrdup()'ing the pointer when saving it.

Now i am facing a little problem and my knowledge of c is still to limited to get me out of this one...
The struct i store in there contains references to a few other datastructures as well as a reference to the next struct in the list.
Now this all works fine, but when  a channel is dropped for example, the core clears the content of ModuleData  and thus my reference to the list. No problem as i don't need it anymore, but even though the structs only contain references, i am not sure whether the structs need to be free()'ed. Currently this is imossible as i lost my only reference to it but i could probably work around by keeping a list... I mainly use the moduledata to prevent having to go through huge lists all the time..

Another problem is that the core uses its own implementation of  moduleDelData and thus performs a free() on a reference to the struct that has been parsed to a char. Could this cause any problems ?

any help is greatly appreciated..

[Edited on 28-3-2007 by Viper]