Code

Imported upstream version 1.3.5.
[pkg-rrdtool.git] / src / rrd_rpncalc.c
index 005048fad7e960b2d8449eeeee36ed95b18b0ab4..06b91bd72eba92b46ebdb2b445d721fc563f671c 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * RRDtool 1.3.1  Copyright by Tobi Oetiker, 1997-2008
+ * RRDtool 1.3.5  Copyright by Tobi Oetiker, 1997-2008
  ****************************************************************************
  * rrd_rpncalc.c  RPN calculator functions
  ****************************************************************************/
 #include <limits.h>
 #include <locale.h>
 
+#ifdef WIN32
+#include <stdlib.h>
+#endif
+
 short     addop2str(
     enum op_en op,
     enum op_en op_type,
@@ -73,7 +77,7 @@ rpnp_t   *rpn_expand(
     if (rpnp == NULL)
         return NULL;
     for (i = 0; rpnc[i].op != OP_END; ++i) {
-        rpnp[i].op = (long) rpnc[i].op;
+        rpnp[i].op = (enum op_en) rpnc[i].op;
         if (rpnp[i].op == OP_NUMBER) {
             rpnp[i].val = (double) rpnc[i].val;
         } else if (rpnp[i].op == OP_VARIABLE || rpnp[i].op == OP_PREV_OTHER) {
@@ -106,7 +110,7 @@ void rpn_compact2str(
             (*str)[offset++] = ',';
 
 #define add_op(VV,VVV) \
-         if (addop2str(rpnc[i].op, VV, VVV, str, &offset) == 1) continue;
+         if (addop2str((enum op_en)(rpnc[i].op), VV, VVV, str, &offset) == 1) continue;
 
         if (rpnc[i].op == OP_NUMBER) {
             /* convert a short into a string */
@@ -132,7 +136,7 @@ void rpn_compact2str(
 #undef add_op
 
 #define add_op(VV,VVV) \
-         if (addop2str(rpnc[i].op, VV, #VVV, str, &offset) == 1) continue;
+         if (addop2str((enum op_en)rpnc[i].op, VV, #VVV, str, &offset) == 1) continue;
 
         add_op(OP_ADD, +)
             add_op(OP_SUB, -)
@@ -461,9 +465,9 @@ short rpn_calc(
         if (stptr + 5 > rpnstack->dc_stacksize) {
             /* could move this to a separate function */
             rpnstack->dc_stacksize += rpnstack->dc_stackblock;
-            rpnstack->s = rrd_realloc(rpnstack->s,
+            rpnstack->s = (double*)(rrd_realloc(rpnstack->s,
                                       (rpnstack->dc_stacksize) *
-                                      sizeof(*(rpnstack->s)));
+                                                            sizeof(*(rpnstack->s))));
             if (rpnstack->s == NULL) {
                 rrd_set_error("RPN stack overflow");
                 return -1;