changeset 10790:f2ebdd15d1f0 draft

(svn r15123) -Fix [NoAI]: 'const char *' implies that the return value should not be free'd, which is should .. so make them 'char *'
author truebrain <truebrain@openttd.org>
date Sat, 17 Jan 2009 15:31:30 +0000
parents 64f89a0c2bdc
children e0371993d4fd
files src/ai/api/ai_bridge.cpp src/ai/api/ai_bridge.hpp src/ai/api/ai_cargo.cpp src/ai/api/ai_cargo.hpp src/ai/api/ai_company.cpp src/ai/api/ai_company.hpp src/ai/api/ai_engine.cpp src/ai/api/ai_engine.hpp src/ai/api/ai_error.cpp src/ai/api/ai_error.hpp src/ai/api/ai_event_types.cpp src/ai/api/ai_event_types.hpp src/ai/api/ai_group.cpp src/ai/api/ai_group.hpp src/ai/api/ai_industry.cpp src/ai/api/ai_industry.hpp src/ai/api/ai_industrytype.cpp src/ai/api/ai_industrytype.hpp src/ai/api/ai_sign.cpp src/ai/api/ai_sign.hpp src/ai/api/ai_station.cpp src/ai/api/ai_station.hpp src/ai/api/ai_town.cpp src/ai/api/ai_town.hpp src/ai/api/ai_vehicle.cpp src/ai/api/ai_vehicle.hpp
diffstat 26 files changed, 31 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/src/ai/api/ai_bridge.cpp
+++ b/src/ai/api/ai_bridge.cpp
@@ -120,7 +120,7 @@
 	return AIObject::DoCommand(tile, 0, 0, CMD_LANDSCAPE_CLEAR);
 }
 
-/* static */ const char *AIBridge::GetName(BridgeID bridge_id)
+/* static */ char *AIBridge::GetName(BridgeID bridge_id)
 {
 	if (!IsValidBridge(bridge_id)) return NULL;
 
--- a/src/ai/api/ai_bridge.hpp
+++ b/src/ai/api/ai_bridge.hpp
@@ -57,7 +57,7 @@
 	 * @pre IsValidBridge(bridge_id).
 	 * @return The name the bridge has.
 	 */
-	static const char *GetName(BridgeID bridge_id);
+	static char *GetName(BridgeID bridge_id);
 
 	/**
 	 * Get the maximum speed of a bridge (in km/h).
--- a/src/ai/api/ai_cargo.cpp
+++ b/src/ai/api/ai_cargo.cpp
@@ -15,7 +15,7 @@
 	return (cargo_type < NUM_CARGO && ::GetCargo(cargo_type)->IsValid());
 }
 
-/* static */ const char *AICargo::GetCargoLabel(CargoID cargo_type)
+/* static */ char *AICargo::GetCargoLabel(CargoID cargo_type)
 {
 	if (!IsValidCargo(cargo_type)) return NULL;
 	const CargoSpec *cargo = ::GetCargo(cargo_type);
--- a/src/ai/api/ai_cargo.hpp
+++ b/src/ai/api/ai_cargo.hpp
@@ -56,7 +56,7 @@
 	 * @note Never use this to check if it is a certain cargo. NewGRF can
 	 *  redefine all of the names.
 	 */
-	static const char *GetCargoLabel(CargoID cargo_type);
+	static char *GetCargoLabel(CargoID cargo_type);
 
 	/**
 	 * Checks whether the give cargo is a freight or not.
--- a/src/ai/api/ai_company.cpp
+++ b/src/ai/api/ai_company.cpp
@@ -43,13 +43,13 @@
 	return AIObject::DoCommand(0, 0, 0, CMD_RENAME_COMPANY, name);
 }
 
-/* static */ const char *AICompany::GetCompanyName(AICompany::CompanyID company)
+/* static */ char *AICompany::GetCompanyName(AICompany::CompanyID company)
 {
 	AILog::Error("AICompany::GetCompanyName is obsolete. Use AICompany::GetName instead.");
 	return AICompany::GetName(company);
 }
 
-/* static */ const char *AICompany::GetName(AICompany::CompanyID company)
+/* static */ char *AICompany::GetName(AICompany::CompanyID company)
 {
 	company = ResolveCompanyID(company);
 	if (company == COMPANY_INVALID) return NULL;
@@ -69,7 +69,7 @@
 	return AIObject::DoCommand(0, 0, 0, CMD_RENAME_PRESIDENT, name);
 }
 
-/* static */ const char *AICompany::GetPresidentName(AICompany::CompanyID company)
+/* static */ char *AICompany::GetPresidentName(AICompany::CompanyID company)
 {
 	company = ResolveCompanyID(company);
 
--- a/src/ai/api/ai_company.hpp
+++ b/src/ai/api/ai_company.hpp
@@ -61,7 +61,7 @@
 	/**
 	 * Obsolete, use AICompany::GetName instead.
 	 */
-	static const char *GetCompanyName(CompanyID company);
+	static char *GetCompanyName(CompanyID company);
 
 	/**
 	 * Get the name of the given company.
@@ -69,7 +69,7 @@
 	 * @pre ResolveCompanyID(company) != COMPANY_INVALID
 	 * @return The name of the given company.
 	 */
-	static const char *GetName(CompanyID company);
+	static char *GetName(CompanyID company);
 
 	/**
 	 * Set the name of your president.
@@ -86,7 +86,7 @@
 	 * @pre ResolveCompanyID(company) != COMPANY_INVALID
 	 * @return The name of the president of the given company.
 	 */
-	static const char *GetPresidentName(CompanyID company);
+	static char *GetPresidentName(CompanyID company);
 
 	/**
 	 * Sets the amount to loan.
--- a/src/ai/api/ai_engine.cpp
+++ b/src/ai/api/ai_engine.cpp
@@ -25,7 +25,7 @@
 	return ::IsEngineIndex(engine_id) && HasBit(::GetEngine(engine_id)->company_avail, _current_company);
 }
 
-/* static */ const char *AIEngine::GetName(EngineID engine_id)
+/* static */ char *AIEngine::GetName(EngineID engine_id)
 {
 	if (!IsValidEngine(engine_id)) return NULL;
 
--- a/src/ai/api/ai_engine.hpp
+++ b/src/ai/api/ai_engine.hpp
@@ -31,7 +31,7 @@
 	 * @pre IsValidEngine(engine_id).
 	 * @return The name the engine has.
 	 */
-	static const char *GetName(EngineID engine_id);
+	static char *GetName(EngineID engine_id);
 
 	/**
 	 * Get the cargo-type of an engine. In case it can transport 2 cargos, it
--- a/src/ai/api/ai_error.cpp
+++ b/src/ai/api/ai_error.cpp
@@ -14,9 +14,9 @@
 	return AIObject::GetLastError();
 }
 
-/* static */ const char *AIError::GetLastErrorString()
+/* static */ char *AIError::GetLastErrorString()
 {
-	return (*error_map_string.find(AIError::GetLastError())).second;
+	return strdup((*error_map_string.find(AIError::GetLastError())).second);
 }
 
 /* static */ AIErrorType AIError::StringToError(StringID internal_string_id)
--- a/src/ai/api/ai_error.hpp
+++ b/src/ai/api/ai_error.hpp
@@ -134,7 +134,7 @@
 	 * Get the last error in string format (for human readability).
 	 * @return An ErrorMessage enum item, as string.
 	 */
-	static const char *GetLastErrorString();
+	static char *GetLastErrorString();
 
 	/**
 	 * Get the error based on the OpenTTD StringID.
--- a/src/ai/api/ai_event_types.cpp
+++ b/src/ai/api/ai_event_types.cpp
@@ -19,7 +19,7 @@
 	return false;
 }
 
-const char *AIEventEnginePreview::GetName()
+char *AIEventEnginePreview::GetName()
 {
 	static const int len = 64;
 	char *engine_name = MallocT<char>(len);
--- a/src/ai/api/ai_event_types.hpp
+++ b/src/ai/api/ai_event_types.hpp
@@ -254,7 +254,7 @@
 	 * Get the name of the offered engine.
 	 * @return The name the engine has.
 	 */
-	const char *GetName();
+	char *GetName();
 
 	/**
 	 * Get the cargo-type of the offered engine. In case it can transport 2 cargos, it
--- a/src/ai/api/ai_group.cpp
+++ b/src/ai/api/ai_group.cpp
@@ -52,7 +52,7 @@
 	return AIObject::DoCommand(0, group_id, 0, CMD_RENAME_GROUP, name);
 }
 
-/* static */ const char *AIGroup::GetName(GroupID group_id)
+/* static */ char *AIGroup::GetName(GroupID group_id)
 {
 	if (!IsValidGroup(group_id)) return NULL;
 
--- a/src/ai/api/ai_group.hpp
+++ b/src/ai/api/ai_group.hpp
@@ -77,7 +77,7 @@
 	 * @pre IsValidGroup(group_id).
 	 * @return The name the group has.
 	 */
-	static const char *GetName(GroupID group_id);
+	static char *GetName(GroupID group_id);
 
 	/**
 	 * Enable or disable autoreplace protected. If the protection is
--- a/src/ai/api/ai_industry.cpp
+++ b/src/ai/api/ai_industry.cpp
@@ -27,7 +27,7 @@
 	return ::IsValidIndustryID(industry_id);
 }
 
-/* static */ const char *AIIndustry::GetName(IndustryID industry_id)
+/* static */ char *AIIndustry::GetName(IndustryID industry_id)
 {
 	if (!IsValidIndustry(industry_id)) return NULL;
 	static const int len = 64;
--- a/src/ai/api/ai_industry.hpp
+++ b/src/ai/api/ai_industry.hpp
@@ -43,7 +43,7 @@
 	 * @pre IsValidIndustry(industry_id).
 	 * @return The name of the industry.
 	 */
-	static const char *GetName(IndustryID industry_id);
+	static char *GetName(IndustryID industry_id);
 
 	/**
 	 * Gets the production of a cargo of the industry.
--- a/src/ai/api/ai_industrytype.cpp
+++ b/src/ai/api/ai_industrytype.cpp
@@ -40,7 +40,7 @@
 	return ::GetIndustrySpec(industry_type)->GetConstructionCost();
 }
 
-/* static */ const char *AIIndustryType::GetName(IndustryType industry_type)
+/* static */ char *AIIndustryType::GetName(IndustryType industry_type)
 {
 	if (!IsValidIndustryType(industry_type)) return NULL;
 	static const int len = 64;
--- a/src/ai/api/ai_industrytype.hpp
+++ b/src/ai/api/ai_industrytype.hpp
@@ -29,7 +29,7 @@
 	 * @pre IsValidIndustryType(industry_type).
 	 * @return The name of an industry.
 	 */
-	static const char *GetName(IndustryType industry_type);
+	static char *GetName(IndustryType industry_type);
 
 	/**
 	 * Get a list of CargoID possible produced by this industry-type.
--- a/src/ai/api/ai_sign.cpp
+++ b/src/ai/api/ai_sign.cpp
@@ -33,7 +33,7 @@
 	return AIObject::DoCommand(0, sign_id, 0, CMD_RENAME_SIGN, name);
 }
 
-/* static */ const char *AISign::GetName(SignID sign_id)
+/* static */ char *AISign::GetName(SignID sign_id)
 {
 	if (!IsValidSign(sign_id)) return NULL;
 
--- a/src/ai/api/ai_sign.hpp
+++ b/src/ai/api/ai_sign.hpp
@@ -60,7 +60,7 @@
 	 * @pre IsValidSign(sign_id).
 	 * @return The name of the sign.
 	 */
-	static const char *GetName(SignID sign_id);
+	static char *GetName(SignID sign_id);
 
 	/**
 	 * Gets the location of the sign.
--- a/src/ai/api/ai_station.cpp
+++ b/src/ai/api/ai_station.cpp
@@ -30,7 +30,7 @@
 	return ::GetStationIndex(tile);
 }
 
-/* static */ const char *AIStation::GetName(StationID station_id)
+/* static */ char *AIStation::GetName(StationID station_id)
 {
 	if (!IsValidStation(station_id)) return NULL;
 
--- a/src/ai/api/ai_station.hpp
+++ b/src/ai/api/ai_station.hpp
@@ -70,7 +70,7 @@
 	 * @pre IsValidStation(station_id).
 	 * @return The name of the station.
 	 */
-	static const char *GetName(StationID station_id);
+	static char *GetName(StationID station_id);
 
 	/**
 	 * Set the name this station.
--- a/src/ai/api/ai_town.cpp
+++ b/src/ai/api/ai_town.cpp
@@ -30,7 +30,7 @@
 	return ::IsValidTownID(town_id);
 }
 
-/* static */ const char *AITown::GetName(TownID town_id)
+/* static */ char *AITown::GetName(TownID town_id)
 {
 	if (!IsValidTown(town_id)) return NULL;
 	static const int len = 64;
--- a/src/ai/api/ai_town.hpp
+++ b/src/ai/api/ai_town.hpp
@@ -112,7 +112,7 @@
 	 * @pre IsValidTown(town_id).
 	 * @return The name of the town.
 	 */
-	static const char *GetName(TownID town_id);
+	static char *GetName(TownID town_id);
 
 	/**
 	 * Gets the number of inhabitants in the town.
--- a/src/ai/api/ai_vehicle.cpp
+++ b/src/ai/api/ai_vehicle.cpp
@@ -227,7 +227,7 @@
 	return ::GetVehicle(vehicle_id)->unitnumber;
 }
 
-/* static */ const char *AIVehicle::GetName(VehicleID vehicle_id)
+/* static */ char *AIVehicle::GetName(VehicleID vehicle_id)
 {
 	if (!IsValidVehicle(vehicle_id)) return NULL;
 
--- a/src/ai/api/ai_vehicle.hpp
+++ b/src/ai/api/ai_vehicle.hpp
@@ -126,7 +126,7 @@
 	 * @pre IsValidVehicle(vehicle_id).
 	 * @return The name the vehicle has.
 	 */
-	static const char *GetName(VehicleID vehicle_id);
+	static char *GetName(VehicleID vehicle_id);
 
 	/**
 	 * Get the current location of a vehicle.