Anope IRC Services

Please login or register.

Login with username, password and session length
Advanced search  


Pages: [1]   Go Down

Author Topic: Using moduledata to store structs...  (Read 4063 times)

0 Members and 1 Guest are viewing this topic.

Jan Milants

  • Team
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 1372
Using moduledata to store structs...
« 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]
If you like me donate coins to 1FBmZVT4J8WAUMHKqpWhgNVj3XXnRN1cCk :)
Pages: [1]   Go Up