use size_t instead of int when work with strings

This commit is contained in:
Sergey Sushilin 2019-12-01 22:45:42 +03:00
parent df72b8d487
commit 14fc6b6dcb
2 changed files with 5 additions and 5 deletions

View File

@ -132,7 +132,7 @@ BOOL WINAPI DllMain (HINSTANCE hDll, DWORD dwReason, LPVOID lpReserved)
/********************************************************/
/* copy a string and truncate it. */
ST_FUNC char *pstrcpy(char *buf, int buf_size, const char *s)
ST_FUNC char *pstrcpy(char *buf, size_t buf_size, const char *s)
{
char *q, *q_end;
int c;
@ -152,9 +152,9 @@ ST_FUNC char *pstrcpy(char *buf, int buf_size, const char *s)
}
/* strcat and truncate. */
ST_FUNC char *pstrcat(char *buf, int buf_size, const char *s)
ST_FUNC char *pstrcat(char *buf, size_t buf_size, const char *s)
{
int len;
size_t len;
len = strlen(buf);
if (len < buf_size)
pstrcpy(buf + len, buf_size - len, s);

4
tcc.h
View File

@ -1120,8 +1120,8 @@ ST_DATA int tcc_ext;
ST_DATA struct TCCState *tcc_state;
/* public functions currently used by the tcc main function */
ST_FUNC char *pstrcpy(char *buf, int buf_size, const char *s);
ST_FUNC char *pstrcat(char *buf, int buf_size, const char *s);
ST_FUNC char *pstrcpy(char *buf, size_t buf_size, const char *s);
ST_FUNC char *pstrcat(char *buf, size_t buf_size, const char *s);
ST_FUNC char *pstrncpy(char *out, const char *in, size_t num);
PUB_FUNC char *tcc_basename(const char *name);
PUB_FUNC char *tcc_fileextension (const char *name);