Changeset - r21411:867b7272b2ab
[Not reviewed]
master
0 1 0
rubidium - 10 years ago 2014-04-25 17:35:29
rubidium@openttd.org
(svn r26510) -Codechange: use memcpy instead of strncpy in the town name replace word function since we never want to add a '\0' anyway, and we know the exact length too
1 file changed with 2 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/townname.cpp
Show inline comments
 
@@ -199,13 +199,14 @@ static inline int32 SeedChanceBias(byte 
 
 * @param org string to replace, has to be 4 characters long
 
 * @param rep string to be replaced with, has to be 4 characters long
 
 * @param buf buffer with string
 
 */
 
static void ReplaceWords(const char *org, const char *rep, char *buf)
 
{
 
	if (strncmp(buf, org, 4) == 0) strncpy(buf, rep, 4); // Safe as the string in buf is always more than 4 characters long.
 
	assert(strlen(org) == 4 && strlen(rep) == 4 && strlen(buf) >= 4);
 
	if (strncmp(buf, org, 4) == 0) memcpy(buf, rep, 4); // Safe as the string in buf is always more than 4 characters long.
 
}
 

	
 

	
 
/**
 
 * Replaces english curses and ugly letter combinations by nicer ones.
 
 * @param buf buffer with town name
0 comments (0 inline, 0 general)