forked from weirdhome

Fork of HTTPClient by David Smart

Revision:
43:12a6ae712bcd
Parent:
42:ab259a9d1d36
Child:
44:0e3b0849b2c7
diff -r ab259a9d1d36 -r 12a6ae712bcd data/HTTPiCal.cpp
--- a/data/HTTPiCal.cpp	Sun Jun 04 15:51:38 2017 +0000
+++ b/data/HTTPiCal.cpp	Thu Jul 20 10:56:03 2017 +0000
@@ -192,12 +192,16 @@
     return tStamp;
 }
 
+// since this returns the string from a static buffer, and unknowing users
+// might call this twice in a single command (e.g. printf(..., FormatCTime(time1), FormatCTime(time2));
+// this define controls how many of these can execute.
+#define NumCallsPerArgList 2
 char * HTTPiCal::FormatCTime(time_t t)
 {
-    static char temp[4][80];
+    static char temp[NumCallsPerArgList][80];
     static int i = 0;
 
-    i &= 3;
+    i %= NumCallsPerArgList;
     strcpy(temp[i], ctime(&t));
     temp[i][strlen(temp[i])-1] = '\0';
     return temp[i++];