src/driver.cpp
branchnoai
changeset 11126 72d4c9314c72
parent 11044 097ea3e7ec56
equal deleted inserted replaced
11111:1b984dab8cec 11126:72d4c9314c72
   154 	/* Prefix the name with driver type to make it unique */
   154 	/* Prefix the name with driver type to make it unique */
   155 	char buf[32];
   155 	char buf[32];
   156 	strecpy(buf, GetDriverTypeName(type), lastof(buf));
   156 	strecpy(buf, GetDriverTypeName(type), lastof(buf));
   157 	strecpy(buf + 5, name, lastof(buf));
   157 	strecpy(buf + 5, name, lastof(buf));
   158 
   158 
   159 	std::pair<Drivers::iterator, bool> P = GetDrivers().insert(Drivers::value_type(buf, this));
   159 	const char *longname = strdup(buf);
       
   160 
       
   161 	std::pair<Drivers::iterator, bool> P = GetDrivers().insert(Drivers::value_type(longname, this));
   160 	assert(P.second);
   162 	assert(P.second);
   161 }
   163 }
   162 
   164 
   163 /**
   165 /**
   164  * Build a human readable list of available drivers, grouped by type.
   166  * Build a human readable list of available drivers, grouped by type.
   192 	/* Prefix the name with driver type to make it unique */
   194 	/* Prefix the name with driver type to make it unique */
   193 	char buf[32];
   195 	char buf[32];
   194 	strecpy(buf, GetDriverTypeName(type), lastof(buf));
   196 	strecpy(buf, GetDriverTypeName(type), lastof(buf));
   195 	strecpy(buf + 5, this->name, lastof(buf));
   197 	strecpy(buf + 5, this->name, lastof(buf));
   196 
   198 
   197 	GetDrivers().erase(buf);
   199 	Drivers::iterator it = GetDrivers().find(buf);
       
   200 	assert(it != GetDrivers().end());
       
   201 
       
   202 	const char *longname = (*it).first;
       
   203 
       
   204 	GetDrivers().erase(it);
       
   205 	free((void *)longname);
       
   206 
   198 	if (GetDrivers().empty()) delete &GetDrivers();
   207 	if (GetDrivers().empty()) delete &GetDrivers();
   199 	free(this->name);
   208 	free((void *)this->name);
   200 }
   209 }