Changeset: 2f268fab8545 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/2f268fab8545
Modified Files:
        monetdb5/mal/mal_exception.c
        monetdb5/mal/mal_profiler.c
Branch: Jun2023
Log Message:

A little cleanup.


diffs (100 lines):

diff --git a/monetdb5/mal/mal_exception.c b/monetdb5/mal/mal_exception.c
--- a/monetdb5/mal/mal_exception.c
+++ b/monetdb5/mal/mal_exception.c
@@ -76,7 +76,7 @@ concatErrors(char *err1, const char *err
  * is good.
  */
 static str __attribute__((__format__(__printf__, 3, 0), __returns_nonnull__))
-               createExceptionInternal(enum malexception type, const char *fcn,
+createExceptionInternal(enum malexception type, const char *fcn,
                                                const char *format, va_list ap)
 {
        size_t msglen;
@@ -196,7 +196,7 @@ freeException(str msg)
  * is good.
  */
 static str __attribute__((__format__(__printf__, 5, 0), __returns_nonnull__))
-               createMalExceptionInternal(MalBlkPtr mb, int pc, enum 
malexception type,
+createMalExceptionInternal(MalBlkPtr mb, int pc, enum malexception type,
                                                   char *prev, const char 
*format, va_list ap)
 {
        bool addnl = false;
diff --git a/monetdb5/mal/mal_profiler.c b/monetdb5/mal/mal_profiler.c
--- a/monetdb5/mal/mal_profiler.c
+++ b/monetdb5/mal/mal_profiler.c
@@ -127,48 +127,43 @@ logadd(struct logbuf *logbuf, const char
        char tmp_buff[LOGLEN];
        int tmp_len;
        va_list va;
-       va_list va2;
 
        va_start(va, fmt);
-       va_copy(va2, va);                       /* we will need it again */
        tmp_len = vsnprintf(tmp_buff, sizeof(tmp_buff), fmt, va);
+       va_end(va);
        if (tmp_len < 0) {
                logdel(logbuf);
-               va_end(va);
-               va_end(va2);
                return false;
        }
+       if (logbuf->loglen + (size_t) tmp_len >= logbuf->logcap) {
+               if ((size_t) tmp_len >= logbuf->logcap) {
+                       /* includes first time when logbuffer == NULL and 
logcap == 0 */
+                       char *alloc_buff;
+                       if (logbuf->loglen > 0)
+                               logjsonInternal(logbuf->logbuffer, false);
+                       logbuf->logcap = (size_t) tmp_len + (size_t) tmp_len / 
2;
+                       if (logbuf->logcap < LOGLEN)
+                               logbuf->logcap = LOGLEN;
+                       alloc_buff = GDKrealloc(logbuf->logbuffer, 
logbuf->logcap);
+                       if (alloc_buff == NULL) {
+                               TRC_ERROR(MAL_SERVER,
+                                                 "Profiler JSON buffer 
reallocation failure\n");
+                               logdel(logbuf);
+                               return false;
+                       }
+                       logbuf->logbuffer = alloc_buff;
+                       lognew(logbuf);
+               } else {
+                       logjsonInternal(logbuf->logbuffer, false);
+                       lognew(logbuf);
+               }
+       }
        if (tmp_len > 0) {
-               if (logbuf->loglen + (size_t) tmp_len >= logbuf->logcap) {
-                       if ((size_t) tmp_len >= logbuf->logcap) {
-                               /* includes first time when logbuffer == NULL 
and logcap == 0 */
-                               char *alloc_buff;
-                               if (logbuf->loglen > 0)
-                                       logjsonInternal(logbuf->logbuffer, 
false);
-                               logbuf->logcap = (size_t) tmp_len + (size_t) 
tmp_len / 2;
-                               if (logbuf->logcap < LOGLEN)
-                                       logbuf->logcap = LOGLEN;
-                               alloc_buff = GDKrealloc(logbuf->logbuffer, 
logbuf->logcap);
-                               if (alloc_buff == NULL) {
-                                       TRC_ERROR(MAL_SERVER,
-                                                         "Profiler JSON buffer 
reallocation failure\n");
-                                       logdel(logbuf);
-                                       va_end(va);
-                                       va_end(va2);
-                                       return false;
-                               }
-                               logbuf->logbuffer = alloc_buff;
-                               lognew(logbuf);
-                       } else {
-                               logjsonInternal(logbuf->logbuffer, false);
-                               lognew(logbuf);
-                       }
-               }
+               va_start(va, fmt);
                logbuf->loglen += vsnprintf(logbuf->logbase + logbuf->loglen,
-                                                                       
logbuf->logcap - logbuf->loglen, fmt, va2);
+                                                                       
logbuf->logcap - logbuf->loglen, fmt, va);
+               va_end(va);
        }
-       va_end(va);
-       va_end(va2);
        return true;
 }
 
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to