Skip to content

Commit daf3890

Browse files
committed
xrCore/_std_extensions.h: added missing va_end()
Formatting, placed xr_strcpy and xr_strcat together
1 parent f9b5b5e commit daf3890

File tree

1 file changed

+25
-17
lines changed

1 file changed

+25
-17
lines changed

src/xrCore/_std_extensions.h

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -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);
@@ -179,24 +179,40 @@ inline int xr_strcpy(LPSTR destination, size_t const destination_size, LPCSTR so
179179
return strcpy_s(destination, destination_size, source);
180180
}
181181

182+
template <int count>
183+
inline int xr_strcpy(char(&destination)[count], LPCSTR source)
184+
{
185+
return xr_strcpy(destination, count, source);
186+
}
187+
182188
inline int xr_strcat(LPSTR destination, size_t const buffer_size, LPCSTR source)
183189
{
184190
return strcat_s(destination, buffer_size, source);
185191
}
186192

193+
template <int count>
194+
inline int xr_strcat(char(&destination)[count], LPCSTR source)
195+
{
196+
return xr_strcat(destination, count, source);
197+
}
198+
187199
inline int __cdecl xr_sprintf(LPSTR destination, size_t const buffer_size, LPCSTR format_string, ...)
188200
{
189201
va_list args;
190202
va_start(args, format_string);
191-
return vsprintf_s(destination, buffer_size, format_string, args);
203+
const int result = vsprintf_s(destination, buffer_size, format_string, args);
204+
va_end(args);
205+
return result;
192206
}
193207

194208
template <int count>
195209
inline int __cdecl xr_sprintf(char (&destination)[count], LPCSTR format_string, ...)
196210
{
197211
va_list args;
198212
va_start(args, format_string);
199-
return vsprintf_s(destination, count, format_string, args);
213+
const int result = vsprintf_s(destination, count, format_string, args);
214+
va_end(args);
215+
return result;
200216
}
201217
#else // #ifndef MASTER_GOLD
202218

@@ -224,29 +240,21 @@ inline int __cdecl xr_sprintf(LPSTR destination, size_t const buffer_size, LPCST
224240
{
225241
va_list args;
226242
va_start(args, format_string);
227-
return vsnprintf_s(destination, buffer_size, buffer_size - 1, format_string, args);
243+
const int result = vsnprintf_s(destination, buffer_size, buffer_size - 1, format_string, args);
244+
va_end(args);
245+
return result;
228246
}
229247

230248
template <int count>
231249
inline int __cdecl xr_sprintf(char (&destination)[count], LPCSTR format_string, ...)
232250
{
233251
va_list args;
234252
va_start(args, format_string);
235-
return vsnprintf_s(destination, count, count - 1, format_string, args);
253+
const int result = vsnprintf_s(destination, count, count - 1, format_string, args);
254+
va_end(args);
255+
return result;
236256
}
237257
#endif // #ifndef MASTER_GOLD
238-
239-
template <int count>
240-
inline int xr_strcpy(char (&destination)[count], LPCSTR source)
241-
{
242-
return xr_strcpy(destination, count, source);
243-
}
244-
245-
template <int count>
246-
inline int xr_strcat(char (&destination)[count], LPCSTR source)
247-
{
248-
return xr_strcat(destination, count, source);
249-
}
250258
//#endif // #ifndef _EDITOR
251259

252260
inline void MemFill32(void* dst, u32 value, size_t dstSize)

0 commit comments

Comments
 (0)