Skip to content

Commit

Permalink
xrCore/_std_extensions.h: added missing va_end()
Browse files Browse the repository at this point in the history
Formatting, placed xr_strcpy and xr_strcat together
  • Loading branch information
Xottab-DUTY committed Jul 24, 2018
1 parent f9b5b5e commit daf3890
Showing 1 changed file with 25 additions and 17 deletions.
42 changes: 25 additions & 17 deletions src/xrCore/_std_extensions.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ IC int xr_sprintf(char* dest, size_t sizeOfBuffer, const char* format, ...)
#endif // _EDITOR

#if defined(LINUX)
IC int vsnprintf_s( char *buffer, size_t size, size_t count, const char *format, va_list list)
IC int vsnprintf_s(char* buffer, size_t size, size_t count, const char* format, va_list list)
{
//TODO add bound check
return vsnprintf(buffer, size, format, list);
Expand Down Expand Up @@ -179,24 +179,40 @@ inline int xr_strcpy(LPSTR destination, size_t const destination_size, LPCSTR so
return strcpy_s(destination, destination_size, source);
}

template <int count>
inline int xr_strcpy(char(&destination)[count], LPCSTR source)
{
return xr_strcpy(destination, count, source);
}

inline int xr_strcat(LPSTR destination, size_t const buffer_size, LPCSTR source)
{
return strcat_s(destination, buffer_size, source);
}

template <int count>
inline int xr_strcat(char(&destination)[count], LPCSTR source)
{
return xr_strcat(destination, count, source);
}

inline int __cdecl xr_sprintf(LPSTR destination, size_t const buffer_size, LPCSTR format_string, ...)
{
va_list args;
va_start(args, format_string);
return vsprintf_s(destination, buffer_size, format_string, args);
const int result = vsprintf_s(destination, buffer_size, format_string, args);
va_end(args);
return result;
}

template <int count>
inline int __cdecl xr_sprintf(char (&destination)[count], LPCSTR format_string, ...)
{
va_list args;
va_start(args, format_string);
return vsprintf_s(destination, count, format_string, args);
const int result = vsprintf_s(destination, count, format_string, args);
va_end(args);
return result;
}
#else // #ifndef MASTER_GOLD

Expand Down Expand Up @@ -224,29 +240,21 @@ inline int __cdecl xr_sprintf(LPSTR destination, size_t const buffer_size, LPCST
{
va_list args;
va_start(args, format_string);
return vsnprintf_s(destination, buffer_size, buffer_size - 1, format_string, args);
const int result = vsnprintf_s(destination, buffer_size, buffer_size - 1, format_string, args);
va_end(args);
return result;
}

template <int count>
inline int __cdecl xr_sprintf(char (&destination)[count], LPCSTR format_string, ...)
{
va_list args;
va_start(args, format_string);
return vsnprintf_s(destination, count, count - 1, format_string, args);
const int result = vsnprintf_s(destination, count, count - 1, format_string, args);
va_end(args);
return result;
}
#endif // #ifndef MASTER_GOLD

template <int count>
inline int xr_strcpy(char (&destination)[count], LPCSTR source)
{
return xr_strcpy(destination, count, source);
}

template <int count>
inline int xr_strcat(char (&destination)[count], LPCSTR source)
{
return xr_strcat(destination, count, source);
}
//#endif // #ifndef _EDITOR

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

0 comments on commit daf3890

Please sign in to comment.