--- deliantra/server/include/util.h 2006/09/12 18:15:34 1.9 +++ deliantra/server/include/util.h 2006/09/12 19:20:08 1.10 @@ -118,13 +118,14 @@ template static inline void swap (T& a, U& b) { T t=a; a=(T)b; b=(U)t; } -// basically does what strncpy should do +// basically does what strncpy should do, but appends "..." to strings exceeding length +void assign (char *dst, const char *src, int maxlen); + +// type-safe version of assign template inline void assign (char (&dst)[N], const char *src) { - // should be optimised at some point, maybe should also add "..." - // when buffer is too small. - snprintf (dst, N, "%s", src); + assign ((char *)&dst, src, N); } #endif