diff options
author | FlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2007-06-02 20:19:40 +0000 |
---|---|---|
committer | FlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2007-06-02 20:19:40 +0000 |
commit | 85db2023cb033928a190ac7fa6f05b5d6cbad14a (patch) | |
tree | b37ec6dab700ae4170968f10ccf0136242ee5f23 /src/common/strlib.c | |
parent | c6f3f3b4d8e95e130af32ea24d3e30130688eab8 (diff) | |
download | hercules-85db2023cb033928a190ac7fa6f05b5d6cbad14a.tar.gz hercules-85db2023cb033928a190ac7fa6f05b5d6cbad14a.tar.bz2 hercules-85db2023cb033928a190ac7fa6f05b5d6cbad14a.tar.xz hercules-85db2023cb033928a190ac7fa6f05b5d6cbad14a.zip |
* Displaying op names instead of numbers in script engine errors.
* Fixed a bug introduced in the last rework of the fame ranking.
* Created safestrncpy that ensures the string is nul-terminated.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@10667 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/common/strlib.c')
-rw-r--r-- | src/common/strlib.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/common/strlib.c b/src/common/strlib.c index 977dc8306..a683dc100 100644 --- a/src/common/strlib.c +++ b/src/common/strlib.c @@ -1,14 +1,15 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/utils.h" +#include "strlib.h" + #include <stdio.h> #include <stdlib.h> #include <string.h> -#include "strlib.h" -#include "../common/cbasetypes.h" -#include "../common/utils.h" -#include "../common/malloc.h" #define J_MAX_MALLOC_SIZE 65535 @@ -299,3 +300,13 @@ int config_switch(const char* str) return (int)strtol(str, NULL, 0); } + +/// always nul-terminates the string +char* safestrncpy(char* dst, const char* src, size_t n) +{ + char* ret; + ret = strncpy(dst, src, n); + if( ret != NULL ) + ret[n - 1] = '\0'; + return ret; +} |