Changeset: 2567dec6ffe8 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/2567dec6ffe8
Modified Files:
        sql/backends/monet5/sql.c
Branch: userprofile
Log Message:

merge default


diffs (187 lines):

diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -766,3 +766,4 @@ 025239a5a6f122042798c0f1132a2c6298514e06
 2e54857a91306cc6304825c5596f65d00595db6b Jul2021_23
 2e54857a91306cc6304825c5596f65d00595db6b Jul2021_SP6_release
 1252291e5c0ddc91ccb16d612d04e34e6a7d3bc3 Jun2020_13
+1252291e5c0ddc91ccb16d612d04e34e6a7d3bc3 Jun2020_SP2_release
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/gdk/gdk_utils.h b/gdk/gdk_utils.h
--- a/gdk/gdk_utils.h
+++ b/gdk/gdk_utils.h
@@ -167,9 +167,11 @@ gdk_export int GDKms(void);
        ({                                                      \
                void *_ptr = (p);                               \
                size_t _size = (s);                             \
+               char _buf[12];                                  \
+               snprintf(_buf, sizeof(_buf), "%p", _ptr);       \
                void *_res = GDKrealloc(_ptr, _size);           \
-               TRC_DEBUG(ALLOC, "GDKrealloc(%p,%zu) -> %p\n",  \
-                         _ptr, _size, _res);                   \
+               TRC_DEBUG(ALLOC, "GDKrealloc(%s,%zu) -> %p\n",  \
+                         _buf, _size, _res);                   \
                _res;                                           \
         })
 #define GDKfree(p)                                                     \
@@ -238,9 +240,11 @@ gdk_export int GDKms(void);
        ({                                                      \
                void *_ptr = (p);                               \
                size_t _size = (s);                             \
+               char _buf[12];                                  \
+               snprintf(_buf, sizeof(_buf), "%p", _ptr);       \
                void *_res = realloc(_ptr, _size);              \
-               TRC_DEBUG(ALLOC, "realloc(%p,%zu) -> %p\n",     \
-                         _ptr, _size, _res);                   \
+               TRC_DEBUG(ALLOC, "realloc(%s,%zu) -> %p\n",     \
+                         _buf, _size, _res);                   \
                _res;                                           \
         })
 #define free(p)                                                \
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to