Changeset - r25615:0966a6886a7c
[Not reviewed]
master
0 1 0
rubidium42 - 3 years ago 2021-05-30 10:41:45
rubidium@openttd.org
Codechange: [ContentInfo] Do not use memset/memcpy to make it possible to use vector/string
1 file changed with 5 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/network/core/tcp_content.cpp
Show inline comments
 
@@ -22,8 +22,11 @@
 

	
 
/** Clear everything in the struct */
 
ContentInfo::ContentInfo()
 
	: /* Temporary... will be removed later in the PR. */
 
	type((ContentType)0), id((ContentID)0), filesize(0), filename(""), name(""), version(""),
 
	url(""), description(""), unique_id(0), md5sum(""), dependency_count(0), dependencies(nullptr),
 
	tag_count(0), tags(nullptr), state((State)0), upgrade(false)
 
{
 
	memset(this, 0, sizeof(*this));
 
}
 

	
 
/** Free everything allocated */
 
@@ -42,7 +45,7 @@ void ContentInfo::TransferFrom(ContentIn
 
	if (other != this) {
 
		free(this->dependencies);
 
		free(this->tags);
 
		memcpy(this, other, sizeof(ContentInfo));
 
		*this = *other;
 
		other->dependencies = nullptr;
 
		other->tags = nullptr;
 
	}
0 comments (0 inline, 0 general)