commit 7d7d35ae62a8c6d8699ea4f2d493f4ca5a96e5be
parent c52b718b491e0de818a5ec1fad85ebbaa5785550
Author: Claudio Alessi <smoppy@gmail.com>
Date:   Sat, 12 Mar 2016 23:31:37 +0100
Add FLDMAXLEN to config.def.h
Diffstat:
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/config.def.h b/config.def.h
@@ -1,6 +1,7 @@
 /* See LICENSE file for copyright and license details. */
 
 #define FLDSEP " | "
+#define FLDMAXLEN 19 /* MySQL represents a timestamp in 19 chars. */
 
 static const char *dbhost = "";
 static const char *dbuser = "";
diff --git a/core.c b/core.c
@@ -481,8 +481,8 @@ stfl_showfields(Field *fds, int *lens) {
 			maxlen = lens[i];
 
 	txtsz = maxlen + 1;
-	txt = ecalloc(txtsz, sizeof(char)); 
 	linesz = maxlen * nfields + fldseplen * (nfields - 1) + 1;
+	txt = ecalloc(txtsz, sizeof(char)); 
 	line = ecalloc(linesz, sizeof(char));
 
 	for(fld = fds, i = 0; fld; fld = fld->next, ++i) {
@@ -654,8 +654,8 @@ stfl_putitem(Item *item, int *lens) {
 			maxlen = lens[i];
 
 	txtsz = maxlen + 1;
-	txt = ecalloc(txtsz, sizeof(char)); 
 	linesz = maxlen * item->ncols + fldseplen * (item->ncols - 1) + 1;
+	txt = ecalloc(txtsz, sizeof(char)); 
 	line = ecalloc(linesz, sizeof(char)); 
 
 	for(i = 0; i < item->ncols; ++i) {