| 83 | } |
| 84 | |
| 85 | static int |
| 86 | deccall3(decimal *arg1, decimal *arg2, decimal *result, int (*ptr) (numeric *, numeric *, numeric *)) |
| 87 | { |
| 88 | numeric *a1, |
| 89 | *a2, |
| 90 | *nres; |
| 91 | int i; |
| 92 | |
| 93 | /* |
| 94 | * we must NOT set the result to NULL here because it may be the same |
| 95 | * variable as one of the arguments |
| 96 | */ |
| 97 | if (risnull(CDECIMALTYPE, (char *) arg1) || risnull(CDECIMALTYPE, (char *) arg2)) |
| 98 | return 0; |
| 99 | |
| 100 | if ((a1 = PGTYPESnumeric_new()) == NULL) |
| 101 | return ECPG_INFORMIX_OUT_OF_MEMORY; |
| 102 | |
| 103 | if ((a2 = PGTYPESnumeric_new()) == NULL) |
| 104 | { |
| 105 | PGTYPESnumeric_free(a1); |
| 106 | return ECPG_INFORMIX_OUT_OF_MEMORY; |
| 107 | } |
| 108 | |
| 109 | if ((nres = PGTYPESnumeric_new()) == NULL) |
| 110 | { |
| 111 | PGTYPESnumeric_free(a1); |
| 112 | PGTYPESnumeric_free(a2); |
| 113 | return ECPG_INFORMIX_OUT_OF_MEMORY; |
| 114 | } |
| 115 | |
| 116 | if (PGTYPESnumeric_from_decimal(arg1, a1) != 0) |
| 117 | { |
| 118 | PGTYPESnumeric_free(a1); |
| 119 | PGTYPESnumeric_free(a2); |
| 120 | PGTYPESnumeric_free(nres); |
| 121 | return ECPG_INFORMIX_OUT_OF_MEMORY; |
| 122 | } |
| 123 | |
| 124 | if (PGTYPESnumeric_from_decimal(arg2, a2) != 0) |
| 125 | { |
| 126 | PGTYPESnumeric_free(a1); |
| 127 | PGTYPESnumeric_free(a2); |
| 128 | PGTYPESnumeric_free(nres); |
| 129 | return ECPG_INFORMIX_OUT_OF_MEMORY; |
| 130 | } |
| 131 | |
| 132 | i = (*ptr) (a1, a2, nres); |
| 133 | |
| 134 | if (i == 0) /* No error */ |
| 135 | { |
| 136 | |
| 137 | /* set the result to null in case it errors out later */ |
| 138 | rsetnull(CDECIMALTYPE, (char *) result); |
| 139 | PGTYPESnumeric_to_decimal(nres, result); |
| 140 | } |
| 141 | |
| 142 | PGTYPESnumeric_free(nres); |
no test coverage detected