[NeoStats-Devel] [Commits] r2725 - in trunk: include src

[email protected] Sun, 14 Aug 2005 06:04:15 +1000
Newsgroups gmane.comp.neostats.devel
Message-ID <[email protected]>
Author: Mark
Date: Sun Aug 14 04:04:05 2005
New Revision: 2725

Modified:
   trunk/include/modules.h
   trunk/src/modules.c
   trunk/src/services.c
Log:
Tidy up eventlist cleanup and remove erroneous call to free

Modified: trunk/include/modules.h
==============================================================================
--- trunk/include/modules.h	(original)
+++ trunk/include/modules.h	Sun Aug 14 04:04:05 2005
@@ -40,5 +40,5 @@
 void assign_mod_number( Module *mod_ptr );
 void insert_module( Module *mod_ptr );
 void load_module_error( const Client *target, const char *module_name, const char *fmt, ... );
-
+void FreeEventList( Module* mod_ptr );
 #endif /* _MODULES_H_ */

Modified: trunk/src/modules.c
==============================================================================
--- trunk/src/modules.c	(original)
+++ trunk/src/modules.c	Sun Aug 14 04:04:05 2005
@@ -269,7 +269,6 @@
 {
 	int err;
 	void *handle;
-	int moduleindex = 0;
 	ModuleInfo *infoptr = NULL;
 	ModuleEvent *eventlistptr = NULL;
 	Module *mod_ptr = NULL;
@@ -359,7 +358,6 @@
 	}
 	/* assign a module number to this module */
 	assign_mod_number(mod_ptr);
-	dlog(DEBUG1, "Assigned %d to module %s for modulenum", moduleindex, mod_ptr->info->name);
 
 	SET_SEGV_LOCATION();
 	SET_RUN_LEVEL(mod_ptr);
@@ -405,7 +403,6 @@
 	char path[255];
 	char loadmodname[255];
 	struct stat buf;
-	Module *mod;
 
 	strlcpy( loadmodname, modfilename, 255 );
 	strlwr( loadmodname );
@@ -416,6 +413,7 @@
 #ifdef USE_PERL
 	ircsnprintf (path, 255, "%s/%s%s", MOD_PATH, loadmodname, MOD_PERLEXT);
 	if (stat(path, &buf) != -1) {
+		Module *mod;
 		mod = load_perlmodule(path, u);
 		mod->info->build_date = ns_malloc(10);
 		strftime((char *)mod->info->build_date, 9, "%d/%m/%y", gmtime(&buf.st_mtime));
@@ -437,14 +435,15 @@
  * @return Nothing 
  */
 
-void 
-assign_mod_number(Module *mod_ptr) {
+void assign_mod_number( Module *mod_ptr )
+{
 	int moduleindex = 0;
 
 	while (ModList[moduleindex] != NULL)
 		moduleindex++;
 	ModList[moduleindex] = mod_ptr;
 	mod_ptr->modnum = moduleindex;
+	dlog(DEBUG1, "Assigned %d to module %s for modulenum", moduleindex, mod_ptr->info->name);
 }
 
 /** @brief insert module pointer into module hash. 
@@ -524,10 +523,7 @@
 	/* Delete any sockets used by this module */
 	del_sockets (mod_ptr);
 	/* Delete any associated event list */
-	if (mod_ptr->event_list) {
-		ns_free (mod_ptr->event_list);
-		mod_ptr->event_list = NULL;
-	}
+	FreeEventList( mod_ptr );
 	/* Remove from the module hash so we dont call events for this module 
 	 * during signoff 
 	 */
@@ -760,6 +756,19 @@
 
 /** @brief 
  *
+ * 
+ *
+ * @return none
+ */
+void FreeEventList( Module* mod_ptr )
+{
+	if( mod_ptr->event_list )
+		ns_free( mod_ptr->event_list );
+	mod_ptr->event_list = NULL;
+}
+
+/** @brief 
+ *
  * @param 
  * 
  * @return

Modified: trunk/src/services.c
==============================================================================
--- trunk/src/services.c	(original)
+++ trunk/src/services.c	Sun Aug 14 04:04:05 2005
@@ -185,7 +185,7 @@
  *
  *  init NeoStats core
  *
- * @return none
+ *  @return none
  */
 void InitServices( void )
 {
@@ -196,11 +196,11 @@
  *
  *  fini NeoStats core
  *
- * @return none
+ *  @return none
  */
 void FiniServices( void )
 {
-	free(GET_CUR_MODULE()->event_list);
+	FreeEventList( &ns_module );
 }
 
 /** @brief init_services_bot