Changeset: 060266eebc1b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/060266eebc1b
Modified Files:
gdk/gdk.h
Branch: strimps_update
Log Message:
Merged with default
diffs (158 lines):
diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c
--- a/clients/mapilib/mapi.c
+++ b/clients/mapilib/mapi.c
@@ -1046,15 +1046,15 @@ static ATOMIC_FLAG mapi_initialized = AT
return (e); \
} \
} while (0)
-#define REALLOC(p, c) \
- do { \
- if (p) { \
- void *tmp = (p); \
- (p) = realloc((p), (c) * sizeof(*(p))); \
- if ((p) == NULL) \
- free(tmp); \
- } else \
- (p) = malloc((c) * sizeof(*(p))); \
+#define REALLOC(p, c) \
+ do { \
+ if (p) { \
+ void *tmp = realloc((p), (c) * sizeof(*(p))); \
+ if (tmp == NULL) \
+ free(p); \
+ (p) = tmp; \
+ } else \
+ (p) = malloc((c) * sizeof(*(p))); \
} while (0)
/*
@@ -3443,13 +3443,14 @@ mapi_prepare(Mapi mid, const char *cmd)
do { \
/* note: k==strlen(hdl->query) */ \
if (k+len >= lim) { \
- char *q = hdl->query; \
lim = k + len + MAPIBLKSIZE; \
- hdl->query = realloc(hdl->query, lim); \
- if (hdl->query == NULL) { \
- free(q); \
+ char *q = realloc(hdl->query, lim); \
+ if (q == NULL) { \
+ free(hdl->query); \
+ hdl->query = NULL; \
return; \
} \
+ hdl->query = q; \
} \
} while (0)
@@ -3583,14 +3584,15 @@ mapi_param_store(MapiHdl hdl)
val = mapi_quote(buf, 1);
/* note: k==strlen(hdl->query) */
if (k + strlen(val) + 3 >= lim) {
- char *q = hdl->query;
lim = k + strlen(val) + 3 + MAPIBLKSIZE;
- hdl->query = realloc(hdl->query, lim);
- if (hdl->query == NULL) {
- free(q);
+ char *q = realloc(hdl->query, lim);
+ if (q == NULL) {
+ free(hdl->query);
+ hdl->query = NULL;
free(val);
return;
}
+ hdl->query = q;
}
snprintf(hdl->query + k, lim - k, "'%s'", val);
free(val);
@@ -3599,14 +3601,15 @@ mapi_param_store(MapiHdl hdl)
val = mapi_quote((char *) src,
hdl->params[i].sizeptr ? *hdl->params[i].sizeptr : -1);
/* note: k==strlen(hdl->query) */
if (k + strlen(val) + 3 >= lim) {
- char *q = hdl->query;
lim = k + strlen(val) + 3 + MAPIBLKSIZE;
- hdl->query = realloc(hdl->query, lim);
- if (hdl->query == NULL) {
- free(q);
+ char *q = realloc(hdl->query, lim);
+ if (q == NULL) {
+ free(hdl->query);
+ hdl->query = NULL;
free(val);
return;
}
+ hdl->query = q;
}
snprintf(hdl->query + k, lim - k, "'%s'", val);
free(val);
diff --git a/clients/odbc/samples/metadata.c b/clients/odbc/samples/metadata.c
--- a/clients/odbc/samples/metadata.c
+++ b/clients/odbc/samples/metadata.c
@@ -7,6 +7,10 @@
*/
#ifdef _MSC_VER
+/* Visual Studio 8 has deprecated lots of stuff: suppress warnings */
+#ifndef _CRT_SECURE_NO_DEPRECATE
+#define _CRT_SECURE_NO_DEPRECATE 1
+#endif
#include <WTypes.h>
#endif
#include <stdio.h>
diff --git a/gdk/gdk_heap.c b/gdk/gdk_heap.c
--- a/gdk/gdk_heap.c
+++ b/gdk/gdk_heap.c
@@ -152,9 +152,11 @@ HEAPalloc(Heap *h, size_t nitems, size_t
h->free = 0;
h->cleanhash = false;
+ size_t allocated;
if (GDKinmemory(h->farmid) ||
- (GDKmem_cursize() + h->size < GDK_mem_maxsize &&
- h->size < (h->farmid == 0 ? GDK_mmap_minsize_persistent :
GDK_mmap_minsize_transient))) {
+ ((allocated = GDKmem_cursize()) + h->size < GDK_mem_maxsize &&
+ h->size < (h->farmid == 0 ? GDK_mmap_minsize_persistent :
GDK_mmap_minsize_transient) &&
+ h->size < ((GDK_mem_maxsize - allocated) >> 6))) {
h->storage = STORE_MEM;
h->base = GDKmalloc(h->size);
TRC_DEBUG(HEAP, "%s %zu %p\n", h->filename, h->size, h->base);
@@ -244,8 +246,12 @@ HEAPextend(Heap *h, size_t size, bool ma
/* extend a malloced heap, possibly switching over to
* file-mapped storage */
Heap bak = *h;
- bool exceeds_swap = size + GDKmem_cursize() >= GDK_mem_maxsize;
- bool must_mmap = !GDKinmemory(h->farmid) && (exceeds_swap ||
h->newstorage != STORE_MEM || size >= (h->farmid == 0 ?
GDK_mmap_minsize_persistent : GDK_mmap_minsize_transient));
+ size_t allocated;
+ bool must_mmap = (!GDKinmemory(h->farmid) &&
+ (h->newstorage != STORE_MEM ||
+ (allocated = GDKmem_cursize()) + size >=
GDK_mem_maxsize ||
+ size >= (h->farmid == 0 ?
GDK_mmap_minsize_persistent : GDK_mmap_minsize_transient) ||
+ size >= ((GDK_mem_maxsize - allocated) >>
6)));
h->size = size;
@@ -750,8 +756,12 @@ HEAPload_intern(Heap *h, const char *nme
char *srcpath, *dstpath, *tmp;
int t0;
- if (h->storage == STORE_INVALID || h->newstorage == STORE_INVALID)
- h->storage = h->newstorage = h->size < (h->farmid == 0 ?
GDK_mmap_minsize_persistent : GDK_mmap_minsize_transient) ? STORE_MEM :
STORE_MMAP;
+ if (h->storage == STORE_INVALID || h->newstorage == STORE_INVALID) {
+ size_t allocated;
+ h->storage = h->newstorage = h->size < (h->farmid == 0 ?
GDK_mmap_minsize_persistent : GDK_mmap_minsize_transient) &&
+ (allocated = GDKmem_cursize()) < GDK_mem_maxsize &&
+ h->size < ((GDK_mem_maxsize - allocated) >> 6) ?
STORE_MEM : STORE_MMAP;
+ }
minsize = (h->size + GDK_mmap_pagesize - 1) & ~(GDK_mmap_pagesize - 1);
if (h->storage != STORE_MEM && minsize != h->size)
diff --git a/sql/odbc/samples/Tests/metadata.SQL.bat
b/sql/odbc/samples/Tests/metadata.SQL.bat
new file mode 100755
--- /dev/null
+++ b/sql/odbc/samples/Tests/metadata.SQL.bat
@@ -0,0 +1,5 @@
+@echo off
+
+prompt # $t $g
+
+metadata.exe
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]