Changeset: 9f2a6fdc1d4c for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=9f2a6fdc1d4c
Modified Files:
monetdb5/modules/atoms/str.c
monetdb5/modules/atoms/str.h
monetdb5/modules/kernel/batstr.c
Branch: alloc-less-str
Log Message:
Small cleanup
diffs (134 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
@@ -3528,7 +3528,7 @@ illegal:
static str
STRFromWChr(str *res, const int *c)
{
- size_t buflen = INITIAL_STR_BUFFER_LENGTH;
+ size_t buflen = MAX(strlen(str_nil) + 1, 8);
str buf = GDKmalloc(buflen), msg;
*res = NULL;
@@ -4010,7 +4010,7 @@ str_strip2(str *buf, size_t *buflen, int
static str
STRStrip2(str *res, const str *arg1, const str *arg2)
{
- size_t buflen = INITIAL_STR_BUFFER_LENGTH, nchars = buflen *
sizeof(int);
+ size_t buflen = INITIAL_STR_BUFFER_LENGTH, nchars =
INITIAL_INT_BUFFER_LENGTH;
str buf = GDKmalloc(buflen), msg;
int *chars = GDKmalloc(nchars);
@@ -4062,7 +4062,7 @@ str_ltrim2(str *buf, size_t *buflen, int
static str
STRLtrim2(str *res, const str *arg1, const str *arg2)
{
- size_t buflen = INITIAL_STR_BUFFER_LENGTH, nchars = buflen *
sizeof(int);
+ size_t buflen = INITIAL_STR_BUFFER_LENGTH, nchars =
INITIAL_INT_BUFFER_LENGTH;
str buf = GDKmalloc(buflen), msg;
int *chars = GDKmalloc(nchars);
@@ -4114,7 +4114,7 @@ str_rtrim2(str *buf, size_t *buflen, int
static str
STRRtrim2(str *res, const str *arg1, const str *arg2)
{
- size_t buflen = INITIAL_STR_BUFFER_LENGTH, nchars = buflen *
sizeof(int);
+ size_t buflen = INITIAL_STR_BUFFER_LENGTH, nchars =
INITIAL_INT_BUFFER_LENGTH;
str buf = GDKmalloc(buflen), msg;
int *chars = GDKmalloc(nchars);
diff --git a/monetdb5/modules/atoms/str.h b/monetdb5/modules/atoms/str.h
--- a/monetdb5/modules/atoms/str.h
+++ b/monetdb5/modules/atoms/str.h
@@ -15,7 +15,8 @@
/* The batstr module functions use a single buffer to avoid malloc/free
overhead.
Note the buffer should be always large enough to hold null strings, so less
testing will be required */
-#define INITIAL_STR_BUFFER_LENGTH MAX(strlen(str_nil) + 1, 1024)
+#define INITIAL_STR_BUFFER_LENGTH MAX(strlen(str_nil) + 1, 1024)
+#define INITIAL_INT_BUFFER_LENGTH 1024 * sizeof(int)
extern int str_length(const char *s);
extern int str_bytes(const char *s);
diff --git a/monetdb5/modules/kernel/batstr.c b/monetdb5/modules/kernel/batstr.c
--- a/monetdb5/modules/kernel/batstr.c
+++ b/monetdb5/modules/kernel/batstr.c
@@ -23,51 +23,6 @@
#include "mal_exception.h"
#include "str.h"
-#define prepareOperand(X,Y,Z)
\
- if( (X= BATdescriptor(*Y)) == NULL )
\
- throw(MAL, Z, SQLSTATE(HY002) RUNTIME_OBJECT_MISSING);
-#define prepareOperand2(X,Y,A,B,Z)
\
- if( (X= BATdescriptor(*Y)) == NULL )
\
- throw(MAL, Z, SQLSTATE(HY002) RUNTIME_OBJECT_MISSING); \
- if( (A= BATdescriptor(*B)) == NULL ){
\
- BBPunfix(X->batCacheid);
\
- throw(MAL, Z, SQLSTATE(HY002) RUNTIME_OBJECT_MISSING); \
- }
-#define prepareOperand3(X,Y,A,B,I,J,Z)
\
- if( (X= BATdescriptor(*Y)) == NULL )
\
- throw(MAL, Z, SQLSTATE(HY002) RUNTIME_OBJECT_MISSING); \
- if( (A= BATdescriptor(*B)) == NULL ){
\
- BBPunfix(X->batCacheid);
\
- throw(MAL, Z, SQLSTATE(HY002) RUNTIME_OBJECT_MISSING); \
- }
\
- if( (I= BATdescriptor(*J)) == NULL ){
\
- BBPunfix(X->batCacheid);
\
- BBPunfix(A->batCacheid);
\
- throw(MAL, Z, SQLSTATE(HY002) RUNTIME_OBJECT_MISSING); \
- }
-#define prepareResult(X,Y,T,Z)
\
- X= COLnew((Y)->hseqbase,T,BATcount(Y), TRANSIENT); \
- if( X == NULL){
\
- BBPunfix(Y->batCacheid);
\
- throw(MAL, Z, SQLSTATE(HY013) MAL_MALLOC_FAIL); \
- }
\
- X->tsorted=false;
\
- X->trevsorted=false;
-#define prepareResult2(X,Y,A,T,Z)
\
- X= COLnew((Y)->hseqbase,T,BATcount(Y), TRANSIENT); \
- if( X == NULL){
\
- BBPunfix(Y->batCacheid);
\
- BBPunfix(A->batCacheid);
\
- throw(MAL, Z, SQLSTATE(HY013) MAL_MALLOC_FAIL); \
- }
\
- X->tsorted=false;
\
- X->trevsorted=false;
-#define finalizeResult(X,Y,Z)
\
- (Y)->theap.dirty |= BATcount(Y) > 0;
\
- *X = (Y)->batCacheid;
\
- BBPkeepref(*(X));
\
- BBPunfix(Z->batCacheid);
-
static inline str
str_prefix(str *buf, size_t *buflen, const char *s, int l)
{
@@ -183,7 +138,7 @@ STRbatFromWChr(bat *res, const bat *l)
{
BAT *bn = NULL, *b = NULL;
BUN p, q;
- size_t buflen = INITIAL_STR_BUFFER_LENGTH;
+ size_t buflen = MAX(strlen(str_nil) + 1, 8);
int *restrict vals;
str buf = GDKmalloc(buflen), msg = MAL_SUCCEED;
bool nils = false;
@@ -346,7 +301,7 @@ do_batstr_conststr_str(bat *res, const b
BATiter bi;
BAT *bn = NULL, *b = NULL;
BUN p, q;
- size_t buflen = INITIAL_STR_BUFFER_LENGTH, nchars = buflen *
sizeof(int);
+ size_t buflen = INITIAL_STR_BUFFER_LENGTH, nchars =
INITIAL_INT_BUFFER_LENGTH;
str x, y = *s2, buf = GDKmalloc(buflen), msg = MAL_SUCCEED;
int *chars = GDKmalloc(nchars);
bool nils = false;
@@ -405,7 +360,7 @@ do_batstr_batstr_str(bat *res, const bat
BATiter lefti, righti;
BAT *bn = NULL, *left = NULL, *right = NULL;
BUN p, q;
- size_t buflen = INITIAL_STR_BUFFER_LENGTH, nchars = buflen *
sizeof(int);
+ size_t buflen = INITIAL_STR_BUFFER_LENGTH, nchars =
INITIAL_INT_BUFFER_LENGTH;
str x, y, buf = GDKmalloc(buflen), msg = MAL_SUCCEED;
int *chars = GDKmalloc(nchars);
bool nils = false;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list