Changeset: 11e928de4f69 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=11e928de4f69
Modified Files:
monetdb5/modules/atoms/str.c
monetdb5/modules/atoms/str.h
monetdb5/modules/kernel/batstr.c
Branch: alloc-less-str
Log Message:
Use size_t for buffer length
diffs (truncated from 643 to 300 lines):
diff --git a/monetdb5/modules/atoms/str.c b/monetdb5/modules/atoms/str.c
--- a/monetdb5/modules/atoms/str.c
+++ b/monetdb5/modules/atoms/str.c
@@ -3225,7 +3225,7 @@ UTF8_offset(char *restrict s, int n)
} while (0)
static str
-convertCase(BAT *from, BAT *to, str *buf, int *buflen, const char *src, const
char *malfunc)
+convertCase(BAT *from, BAT *to, str *buf, size_t *buflen, const char *src,
const char *malfunc)
{
size_t len = strlen(src);
char *dst;
@@ -3237,7 +3237,7 @@ convertCase(BAT *from, BAT *to, str *buf
return MAL_SUCCEED;
} else {
Hash *h;
- int nextlen = len + 1;
+ size_t nextlen = len + 1;
if (BAThash(from) != GDK_SUCCEED)
throw(MAL, malfunc, SQLSTATE(HY013) MAL_MALLOC_FAIL);
CHECK_STR_BUFFER_LENGTH(buf, buflen, nextlen, malfunc);
@@ -3274,7 +3274,7 @@ convertCase(BAT *from, BAT *to, str *buf
* also allocate enough for the rest of the
* source */
size_t off = dst - *buf;
- int nextlen = (len += 4 + (end - src)) + 1;
+ size_t nextlen = (len += 4 + (end - src)) + 1;
CHECK_STR_BUFFER_LENGTH(buf, buflen, nextlen,
malfunc);
dst = *buf + off;
@@ -3407,7 +3407,7 @@ STRBytes(int *res, const str *arg1)
}
str
-str_tail(str *buf, int *buflen, const char *s, int off)
+str_tail(str *buf, size_t *buflen, const char *s, int off)
{
if (strNil(s) || is_int_nil(off)) {
strcpy(*buf, str_nil);
@@ -3422,7 +3422,7 @@ str_tail(str *buf, int *buflen, const ch
off = 0;
}
str tail = UTF8_strtail(s, off);
- int nextlen = (int) strlen(tail) + 1;
+ size_t nextlen = strlen(tail) + 1;
CHECK_STR_BUFFER_LENGTH(buf, buflen, nextlen, "str.tail");
strcpy(*buf, tail);
return MAL_SUCCEED;
@@ -3431,7 +3431,7 @@ str_tail(str *buf, int *buflen, const ch
static str
STRTail(str *res, const str *arg1, const int *offset)
{
- int buflen = INITIAL_STR_BUFFER_LENGTH;
+ size_t buflen = INITIAL_STR_BUFFER_LENGTH;
str buf = GDKmalloc(buflen), msg;
*res = NULL;
@@ -3447,9 +3447,9 @@ STRTail(str *res, const str *arg1, const
}
str
-str_Sub_String(str *buf, int *buflen, const char *s, int off, int l)
+str_Sub_String(str *buf, size_t *buflen, const char *s, int off, int l)
{
- int len;
+ size_t len;
if (strNil(s) || is_int_nil(off) || is_int_nil(l)) {
strcpy(*buf, str_nil);
@@ -3472,16 +3472,16 @@ str_Sub_String(str *buf, int *buflen, co
return MAL_SUCCEED;
}
s = UTF8_strtail(s, off);
- len = UTF8_strtail(s, l) - s + 1;
+ len = (size_t)(UTF8_strtail(s, l) - s + 1);
CHECK_STR_BUFFER_LENGTH(buf, buflen, len, "str.substring");
- strcpy_len(*buf, s, (size_t) len);
+ strcpy_len(*buf, s, len);
return MAL_SUCCEED;
}
static str
STRSubString(str *res, const str *arg1, const int *offset, const int *length)
{
- int buflen = INITIAL_STR_BUFFER_LENGTH;
+ size_t buflen = INITIAL_STR_BUFFER_LENGTH;
str buf = GDKmalloc(buflen), msg;
*res = NULL;
@@ -3497,7 +3497,7 @@ STRSubString(str *res, const str *arg1,
}
str
-str_from_wchr(str *buf, int *buflen, int c)
+str_from_wchr(str *buf, size_t *buflen, int c)
{
if (is_int_nil(c)) {
strcpy(*buf, str_nil);
@@ -3515,7 +3515,7 @@ illegal:
static str
STRFromWChr(str *res, const int *c)
{
- int buflen = INITIAL_STR_BUFFER_LENGTH;
+ size_t buflen = INITIAL_STR_BUFFER_LENGTH;
str buf = GDKmalloc(buflen), msg;
*res = NULL;
@@ -3599,7 +3599,7 @@ STRSuffix(bit *res, const str *arg1, con
}
str
-str_lower(str *buf, int *buflen, const char *s)
+str_lower(str *buf, size_t *buflen, const char *s)
{
return convertCase(UTF8_toLowerFrom, UTF8_toLowerTo, buf, buflen, s,
"str.lower");
}
@@ -3607,7 +3607,7 @@ str_lower(str *buf, int *buflen, const c
static str
STRLower(str *res, const str *arg1)
{
- int buflen = INITIAL_STR_BUFFER_LENGTH;
+ size_t buflen = INITIAL_STR_BUFFER_LENGTH;
str buf = GDKmalloc(buflen), msg;
*res = NULL;
@@ -3623,7 +3623,7 @@ STRLower(str *res, const str *arg1)
}
str
-str_upper(str *buf, int *buflen, const char *s)
+str_upper(str *buf, size_t *buflen, const char *s)
{
return convertCase(UTF8_toUpperFrom, UTF8_toUpperTo, buf, buflen, s,
"str.upper");
}
@@ -3631,7 +3631,7 @@ str_upper(str *buf, int *buflen, const c
static str
STRUpper(str *res, const str *arg1)
{
- int buflen = INITIAL_STR_BUFFER_LENGTH;
+ size_t buflen = INITIAL_STR_BUFFER_LENGTH;
str buf = GDKmalloc(buflen), msg;
*res = NULL;
@@ -3700,7 +3700,7 @@ STRReverseStrSearch(int *res, const str
}
str
-str_splitpart(str *buf, int *buflen, const char *s, const char *s2, int f)
+str_splitpart(str *buf, size_t *buflen, const char *s, const char *s2, int f)
{
size_t len;
char *p = NULL;
@@ -3733,7 +3733,7 @@ str_splitpart(str *buf, int *buflen, con
}
len++;
- CHECK_STR_BUFFER_LENGTH(buf, buflen, (int) len, "str.splitpart");
+ CHECK_STR_BUFFER_LENGTH(buf, buflen, len, "str.splitpart");
strcpy_len(*buf, s, len);
return MAL_SUCCEED;
}
@@ -3741,7 +3741,7 @@ str_splitpart(str *buf, int *buflen, con
static str
STRsplitpart(str *res, str *haystack, str *needle, int *field)
{
- int buflen = INITIAL_STR_BUFFER_LENGTH;
+ size_t buflen = INITIAL_STR_BUFFER_LENGTH;
str buf = GDKmalloc(buflen), msg;
*res = NULL;
@@ -3831,7 +3831,7 @@ const int whitespace[] = {
#define NSPACES (sizeof(whitespace) / sizeof(whitespace[0]))
str
-str_strip(str *buf, int *buflen, const char *s)
+str_strip(str *buf, size_t *buflen, const char *s)
{
if (strNil(s)) {
strcpy(*buf, str_nil);
@@ -3844,7 +3844,7 @@ str_strip(str *buf, int *buflen, const c
n = rstrip(s, len, whitespace, NSPACES);
n++;
- CHECK_STR_BUFFER_LENGTH(buf, buflen, (int) n, "str.strip");
+ CHECK_STR_BUFFER_LENGTH(buf, buflen, n, "str.strip");
strcpy_len(*buf, s, n);
return MAL_SUCCEED;
}
@@ -3854,7 +3854,7 @@ str_strip(str *buf, int *buflen, const c
static str
STRStrip(str *res, const str *arg1)
{
- int buflen = INITIAL_STR_BUFFER_LENGTH;
+ size_t buflen = INITIAL_STR_BUFFER_LENGTH;
str buf = GDKmalloc(buflen), msg;
*res = NULL;
@@ -3870,7 +3870,7 @@ STRStrip(str *res, const str *arg1)
}
str
-str_ltrim(str *buf, int *buflen, const char *s)
+str_ltrim(str *buf, size_t *buflen, const char *s)
{
if (strNil(s)) {
strcpy(*buf, str_nil);
@@ -3880,7 +3880,7 @@ str_ltrim(str *buf, int *buflen, const c
size_t n = lstrip(s, len, whitespace, NSPACES);
size_t ncast = len - n + 1;
- CHECK_STR_BUFFER_LENGTH(buf, buflen, (int) ncast, "str.ltrim");
+ CHECK_STR_BUFFER_LENGTH(buf, buflen, ncast, "str.ltrim");
strcpy_len(*buf, s + n, ncast);
return MAL_SUCCEED;
}
@@ -3890,7 +3890,7 @@ str_ltrim(str *buf, int *buflen, const c
static str
STRLtrim(str *res, const str *arg1)
{
- int buflen = INITIAL_STR_BUFFER_LENGTH;
+ size_t buflen = INITIAL_STR_BUFFER_LENGTH;
str buf = GDKmalloc(buflen), msg;
*res = NULL;
@@ -3906,7 +3906,7 @@ STRLtrim(str *res, const str *arg1)
}
str
-str_rtrim(str *buf, int *buflen, const char *s)
+str_rtrim(str *buf, size_t *buflen, const char *s)
{
if (strNil(s)) {
strcpy(*buf, str_nil);
@@ -3916,7 +3916,7 @@ str_rtrim(str *buf, int *buflen, const c
size_t n = rstrip(s, len, whitespace, NSPACES);
n++;
- CHECK_STR_BUFFER_LENGTH(buf, buflen, (int) n, "str.strip");
+ CHECK_STR_BUFFER_LENGTH(buf, buflen, n, "str.rtrim");
strcpy_len(*buf, s, n);
return MAL_SUCCEED;
}
@@ -3926,7 +3926,7 @@ str_rtrim(str *buf, int *buflen, const c
static str
STRRtrim(str *res, const str *arg1)
{
- int buflen = INITIAL_STR_BUFFER_LENGTH;
+ size_t buflen = INITIAL_STR_BUFFER_LENGTH;
str buf = GDKmalloc(buflen), msg;
*res = NULL;
@@ -4173,7 +4173,7 @@ STRRpad2(str *res, const str *arg1, cons
}
str
-str_substitute(str *buf, int *buflen, const char *s, const char *src, const
char *dst, bit repeat)
+str_substitute(str *buf, size_t *buflen, const char *s, const char *src, const
char *dst, bit repeat)
{
if (strNil(s) || strNil(src) || strNil(dst)) {
strcpy(*buf, str_nil);
@@ -4192,7 +4192,7 @@ str_substitute(str *buf, int *buflen, co
if (repeat && ldst > lsrc)
n = (ldst * l) / lsrc; /* max length */
- CHECK_STR_BUFFER_LENGTH(buf, buflen, (int) n, "str.substitute");
+ CHECK_STR_BUFFER_LENGTH(buf, buflen, n, "str.substitute");
b = *buf;
pfnd = s;
do {
@@ -4220,7 +4220,7 @@ str_substitute(str *buf, int *buflen, co
static str
STRSubstitute(str *res, const str *arg1, const str *arg2, const str *arg3,
const bit *g)
{
- int buflen = INITIAL_STR_BUFFER_LENGTH;
+ size_t buflen = INITIAL_STR_BUFFER_LENGTH;
str buf = GDKmalloc(buflen), msg;
*res = NULL;
@@ -4242,7 +4242,7 @@ STRascii(int *ret, const str *s)
}
str
-str_substring_tail(str *buf, int *buflen, const char *s, int start)
+str_substring_tail(str *buf, size_t *buflen, const char *s, int start)
{
if (is_int_nil(start)) {
strcpy(*buf, str_nil);
@@ -4256,7 +4256,7 @@ str_substring_tail(str *buf, int *buflen
static str
STRsubstringTail(str *res, const str *s, const int *start)
{
- int buflen = INITIAL_STR_BUFFER_LENGTH;
+ size_t buflen = INITIAL_STR_BUFFER_LENGTH;
str buf = GDKmalloc(buflen), msg;
*res = NULL;
@@ -4272,7 +4272,7 @@ STRsubstringTail(str *res, const str *s,
}
str
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list