mirror of
https://salsa.debian.org/dskoll/remind.git
synced 2026-04-16 06:18:47 +02:00
Use size_t rather than int to track dynamic buffer size.
This lets use create dynamic buffers larger than 2GB.
This commit is contained in:
@@ -1336,7 +1336,7 @@ static void WriteCalTrailer(void)
|
||||
/***************************************************************/
|
||||
static int DoCalRem(ParsePtr p, int col)
|
||||
{
|
||||
int oldLen;
|
||||
size_t oldLen;
|
||||
Trigger trig;
|
||||
TimeTrig tim;
|
||||
Value v;
|
||||
|
||||
@@ -27,11 +27,11 @@
|
||||
Doubles the size of dynamic buffer until it has room for at least
|
||||
'n' characters, not including trailing '\0'
|
||||
**********************************************************************/
|
||||
static int DBufMakeRoom(DynamicBuffer *dbuf, int n)
|
||||
static int DBufMakeRoom(DynamicBuffer *dbuf, size_t n)
|
||||
{
|
||||
/* Double size until it's greater than n (strictly > to leave room
|
||||
for trailing '\0' */
|
||||
int size = dbuf->allocatedLen;
|
||||
size_t size = dbuf->allocatedLen;
|
||||
char *buf;
|
||||
|
||||
if (size > n) return OK;
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
#define DBUF_STATIC_SIZE 128
|
||||
typedef struct {
|
||||
char *buffer;
|
||||
int len;
|
||||
int allocatedLen;
|
||||
size_t len;
|
||||
size_t allocatedLen;
|
||||
char staticBuf[DBUF_STATIC_SIZE];
|
||||
} DynamicBuffer;
|
||||
|
||||
|
||||
@@ -433,7 +433,9 @@ static int FStrlen(func_info *info)
|
||||
Value *v = &ARG(0);
|
||||
if (v->type != STR_TYPE) return E_BAD_TYPE;
|
||||
RetVal.type = INT_TYPE;
|
||||
RETVAL = strlen(v->v.str);
|
||||
size_t l = strlen(v->v.str);
|
||||
if (l > INT_MAX) return E_2HIGH;
|
||||
RETVAL = (int) l;
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -1594,7 +1596,7 @@ static int FShell(func_info *info)
|
||||
DBufFree(&buf);
|
||||
return E_NO_MEM;
|
||||
}
|
||||
if (maxlen > 0 && DBufLen(&buf) >= maxlen) {
|
||||
if (maxlen > 0 && DBufLen(&buf) >= (size_t) maxlen) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user