Changeset - r27628:28ccca9de1b0
[Not reviewed]
master
0 2 0
Rubidium - 12 months ago 2023-06-20 20:58:37
rubidium@openttd.org
Codechange: replace memcpy when copying DParams
2 files changed with 3 insertions and 10 deletions:
0 comments (0 inline, 0 general)
src/strings.cpp
Show inline comments
 
@@ -159,7 +159,7 @@ void SetDParamMaxDigits(size_t n, uint c
 
 */
 
void CopyInDParam(const uint64 *src, int num)
 
{
 
	MemCpyT(_global_string_params.GetPointerToOffset(0), src, num);
 
	for (int i = 0; i < num; i++) SetDParam(i, src[i]);
 
}
 

	
 
/**
 
@@ -169,7 +169,7 @@ void CopyInDParam(const uint64 *src, int
 
 */
 
void CopyOutDParam(uint64 *dst, int num)
 
{
 
	MemCpyT(dst, _global_string_params.GetPointerToOffset(0), num);
 
	for (int i = 0; i < num; i++) dst[i] = GetDParam(i);
 
}
 

	
 
/**
 
@@ -185,13 +185,13 @@ void CopyOutDParam(uint64 *dst, const ch
 
	/* Just get the string to extract the type information. */
 
	GetString(string);
 

	
 
	MemCpyT(dst, _global_string_params.GetPointerToOffset(0), num);
 
	for (int i = 0; i < num; i++) {
 
		if (_global_string_params.GetTypeAtOffset(i) == SCC_RAW_STRING_POINTER) {
 
			strings[i] = stredup((const char *)(size_t)_global_string_params.GetParam(i));
 
			dst[i] = (size_t)strings[i];
 
		} else {
 
			strings[i] = nullptr;
 
			dst[i] = _global_string_params.GetParam(i);
 
		}
 
	}
 
}
src/strings_internal.h
Show inline comments
 
@@ -123,13 +123,6 @@ public:
 
		return this->num_param - this->offset;
 
	}
 

	
 
	/** Get a pointer to a specific element in the data array. */
 
	uint64 *GetPointerToOffset(size_t offset) const
 
	{
 
		assert(offset < this->num_param);
 
		return &this->data[offset];
 
	}
 

	
 
	/** Get the type of a specific element. */
 
	WChar GetTypeAtOffset(size_t offset) const
 
	{
0 comments (0 inline, 0 general)