From 14fc6b6dcbd0314dc653c6eafee6d99fec7ec338 Mon Sep 17 00:00:00 2001 From: Sergey Sushilin Date: Sun, 1 Dec 2019 22:45:42 +0300 Subject: [PATCH] use size_t instead of int when work with strings --- libtcc.c | 6 +++--- tcc.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libtcc.c b/libtcc.c index db30223e..6aa2afd0 100644 --- a/libtcc.c +++ b/libtcc.c @@ -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); diff --git a/tcc.h b/tcc.h index 6c70f33c..59061bc2 100644 --- a/tcc.h +++ b/tcc.h @@ -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);