first bug in clone
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Sun, 03 Oct 2010 23:39:06 +0200
changeset 35 707636758ed3
parent 34 b712b2013056
child 36 eb850eb4a527
first bug in clone
model/cooja-loader-factory.cc
--- a/model/cooja-loader-factory.cc	Sun Oct 03 22:35:42 2010 +0200
+++ b/model/cooja-loader-factory.cc	Sun Oct 03 23:39:06 2010 +0200
@@ -141,11 +141,13 @@
       for (std::list<struct Module *>::iterator j = module->deps.begin ();
 	   j != module->deps.end (); ++j)
 	{
-	  struct Module *dep = clone->SearchModule (module->module->id);
-	  dep->refcount++;
-	  clonedModule->deps.push_back (dep);
+	  struct Module *dep = *j;
+	  struct Module *cloneDep = clone->SearchModule (dep->module->id);
+	  cloneDep->refcount++;
+	  clonedModule->deps.push_back (cloneDep);
 	}
-      clone->m_modules.push_back (module);
+      NS_LOG_DEBUG ("add " << clonedModule->module->id);
+      clone->m_modules.push_back (clonedModule);
     }
   return clone;
 }
@@ -206,13 +208,16 @@
       struct SharedModule *sharedModule = SearchSharedModule (cached.id);
       if (sharedModule == 0)
 	{
-	  void *handle = dlopen (cached.cachedFilename.c_str (), RTLD_LAZY | RTLD_DEEPBIND | RTLD_LOCAL);
+	  void *handle = dlopen (cached.cachedFilename.c_str (), 
+				 RTLD_LAZY | RTLD_DEEPBIND | RTLD_LOCAL);
 	  NS_ASSERT_MSG (handle != 0, "Could not open " << cached.cachedFilename << " " << dlerror ());
 	  struct link_map *link_map;
 	  dlinfo (handle, RTLD_DI_LINKMAP, &link_map);
 
 	  sharedModule = new SharedModule ();
-	  NS_LOG_DEBUG ("create shared module=" << sharedModule << " file=" << cached.cachedFilename);
+	  NS_LOG_DEBUG ("create shared module=" << sharedModule << 
+			" file=" << cached.cachedFilename << 
+			" id=" << cached.id);
 	  sharedModule->refcount = 0;
 	  sharedModule->id = cached.id;
 	  sharedModule->handle = handle;