From 8515d1011cc7dcbbd4db1b80af5496559f3cec87 Mon Sep 17 00:00:00 2001 From: FlavioJS Date: Tue, 27 Nov 2007 23:06:37 +0000 Subject: * Added safesnprintf to strlib.c/h (bugreport:372) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11828 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/common/strlib.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/common/strlib.h') diff --git a/src/common/strlib.h b/src/common/strlib.h index 4df5a51d2..31e364e2a 100644 --- a/src/common/strlib.h +++ b/src/common/strlib.h @@ -37,6 +37,11 @@ char* safestrncpy(char* dst, const char* src, size_t n); /// doesn't crash on null pointer size_t safestrnlen(const char* string, size_t maxlen); +/// Works like snprintf, but always nul-terminates the buffer. +/// Returns the size of the string (without nul-terminator) +/// or -1 if the buffer is too small. +int safesnprintf(char* buf, size_t sz, const char* fmt, ...); + /// Returns the line of the target position in the string. /// Lines start at 1. int strline(const char* str, size_t pos); -- cgit v1.2.3-60-g2f50