@@ -59,7 +59,7 @@ IC int xr_sprintf(char* dest, size_t sizeOfBuffer, const char* format, ...)
5959#endif // _EDITOR
6060
6161#if defined(LINUX)
62- IC int vsnprintf_s ( char * buffer, size_t size, size_t count, const char * format, va_list list)
62+ IC int vsnprintf_s (char * buffer, size_t size, size_t count, const char * format, va_list list)
6363{
6464 // TODO add bound check
6565 return vsnprintf (buffer, size, format, list);
@@ -156,24 +156,40 @@ inline int xr_strcpy(LPSTR destination, size_t const destination_size, LPCSTR so
156156 return strcpy_s (destination, destination_size, source);
157157}
158158
159+ template <int count>
160+ inline int xr_strcpy (char (&destination)[count], LPCSTR source)
161+ {
162+ return xr_strcpy (destination, count, source);
163+ }
164+
159165inline int xr_strcat (LPSTR destination, size_t const buffer_size, LPCSTR source)
160166{
161167 return strcat_s (destination, buffer_size, source);
162168}
163169
170+ template <int count>
171+ inline int xr_strcat (char (&destination)[count], LPCSTR source)
172+ {
173+ return xr_strcat (destination, count, source);
174+ }
175+
164176inline int __cdecl xr_sprintf (LPSTR destination, size_t const buffer_size, LPCSTR format_string, ...)
165177{
166178 va_list args;
167179 va_start (args, format_string);
168- return vsprintf_s (destination, buffer_size, format_string, args);
180+ const int result = vsprintf_s (destination, buffer_size, format_string, args);
181+ va_end (args);
182+ return result;
169183}
170184
171185template <int count>
172186inline int __cdecl xr_sprintf (char (&destination)[count], LPCSTR format_string, ...)
173187{
174188 va_list args;
175189 va_start (args, format_string);
176- return vsprintf_s (destination, count, format_string, args);
190+ const int result = vsprintf_s (destination, count, format_string, args);
191+ va_end (args);
192+ return result;
177193}
178194#else // #ifndef MASTER_GOLD
179195
@@ -201,29 +217,21 @@ inline int __cdecl xr_sprintf(LPSTR destination, size_t const buffer_size, LPCST
201217{
202218 va_list args;
203219 va_start (args, format_string);
204- return vsnprintf_s (destination, buffer_size, buffer_size - 1 , format_string, args);
220+ const int result = vsnprintf_s (destination, buffer_size, buffer_size - 1 , format_string, args);
221+ va_end (args);
222+ return result;
205223}
206224
207225template <int count>
208226inline int __cdecl xr_sprintf (char (&destination)[count], LPCSTR format_string, ...)
209227{
210228 va_list args;
211229 va_start (args, format_string);
212- return vsnprintf_s (destination, count, count - 1 , format_string, args);
230+ const int result = vsnprintf_s (destination, count, count - 1 , format_string, args);
231+ va_end (args);
232+ return result;
213233}
214234#endif // #ifndef MASTER_GOLD
215-
216- template <int count>
217- inline int xr_strcpy (char (&destination)[count], LPCSTR source)
218- {
219- return xr_strcpy (destination, count, source);
220- }
221-
222- template <int count>
223- inline int xr_strcat (char (&destination)[count], LPCSTR source)
224- {
225- return xr_strcat (destination, count, source);
226- }
227235// #endif // #ifndef _EDITOR
228236
229237inline void MemFill32 (void * dst, u32 value, size_t dstSize)
0 commit comments