Replace _snprintf too.
This commit is contained in:
parent
b47aa6871d
commit
62eac5d91c
|
@ -12,6 +12,24 @@
|
|||
#include <stdio.h>
|
||||
#include "commctrl.h"
|
||||
|
||||
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
size_t len = vsnprintf(buffer, maxlength, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (len >= maxlength)
|
||||
{
|
||||
buffer[maxlength - 1] = '\0';
|
||||
return (maxlength - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
return len;
|
||||
}
|
||||
}
|
||||
|
||||
int APIENTRY _tWinMain(HINSTANCE hInstance,
|
||||
HINSTANCE hPrevInstance,
|
||||
LPTSTR lpCmdLine,
|
||||
|
@ -178,7 +196,7 @@ void UpdateListBox(HWND hDlg) {
|
|||
//if ((*b).getPosition() < 1) // umm... naaah!
|
||||
//continue;
|
||||
|
||||
_snprintf(tempbuffer, 1023, "%s", (*b).getName());
|
||||
UTIL_Format(tempbuffer, sizeof(tempbuffer)-1, "%s", (*b).getName());
|
||||
|
||||
SendMessage( // returns LRESULT in lResult
|
||||
listbox, // handle to destination control
|
||||
|
@ -325,7 +343,7 @@ void SaveChanges(HWND hDlg) {
|
|||
UpdateListBox(hDlg);
|
||||
|
||||
char buffer[256];
|
||||
_snprintf(buffer, 255, "New rank of %s: %d", name, newPosition);
|
||||
UTIL_Format(buffer, sizeof(buffer)-1, "New rank of %s: %d", name, newPosition);
|
||||
MessageBox(hDlg, buffer, "Update succeeded", MB_OK);
|
||||
|
||||
// In the listbox, we need to reselect the item we just updated. Use the new name.
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
#include "GeoIP2/maxminddb.h"
|
||||
#include "amxxmodule.h"
|
||||
|
||||
#if defined(WIN32)
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
extern AMX_NATIVE_INFO geoip_natives[];
|
||||
|
||||
#endif //_INCLUDE_GEOIPAMXX_H
|
||||
|
|
|
@ -362,7 +362,7 @@ bool NVault::GetValue(const char *key, time_t &stamp, char buffer[], size_t len)
|
|||
|
||||
sVal = m_Hash.Retrieve(sKey, st);
|
||||
stamp = st;
|
||||
_snprintf(buffer, len, "%s", sVal.c_str());
|
||||
UTIL_Format(buffer, len, "%s", sVal.c_str());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user