summaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/cash.c
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>1998-01-07 18:47:07 +0000
committerBruce Momjian <bruce@momjian.us>1998-01-07 18:47:07 +0000
commite6c6146eb8129f1ea1e1f68ef739c13824357225 (patch)
tree87cb303b9803a3494e74ca7efc760ed6187c667d /src/backend/utils/adt/cash.c
parent7a2a7d436dac73e2b983224458887749078e9796 (diff)
Allow varchar() to only store needed bytes. Remove PALLOC,PALLOCTYPE,PFREE. Clean up use of VARDATA.
Diffstat (limited to 'src/backend/utils/adt/cash.c')
-rw-r--r--src/backend/utils/adt/cash.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/backend/utils/adt/cash.c b/src/backend/utils/adt/cash.c
index dbe34a30a80..7d2f7b937cf 100644
--- a/src/backend/utils/adt/cash.c
+++ b/src/backend/utils/adt/cash.c
@@ -9,7 +9,7 @@
* workings can be found in the book "Software Solutions in C" by
* Dale Schumacher, Academic Press, ISBN: 0-12-632360-7.
*
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/cash.c,v 1.20 1998/01/05 16:39:45 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/cash.c,v 1.21 1998/01/07 18:46:34 momjian Exp $
*/
#include <stdio.h>
@@ -158,7 +158,7 @@ printf( "cashin- precision %d; decimal %c; thousands %c; currency %c; positive %
if (*s != '\0')
elog(ERROR, "Bad money external representation %s", str);
- if (!PointerIsValid(result = PALLOCTYPE(Cash)))
+ if (!PointerIsValid(result = palloc(sizeof(Cash))))
elog(ERROR, "Memory allocation failed, can't input cash '%s'", str);
*result = (value * sgn);
@@ -256,7 +256,7 @@ cash_out(Cash *in_value)
/* see if we need to signify negative amount */
if (minus)
{
- if (!PointerIsValid(result = PALLOC(CASH_BUFSZ + 2 - count + strlen(nsymbol))))
+ if (!PointerIsValid(result = palloc(CASH_BUFSZ + 2 - count + strlen(nsymbol))))
elog(ERROR, "Memory allocation failed, can't output cash", NULL);
/* Position code of 0 means use parens */
@@ -269,7 +269,7 @@ cash_out(Cash *in_value)
}
else
{
- if (!PointerIsValid(result = PALLOC(CASH_BUFSZ + 2 - count)))
+ if (!PointerIsValid(result = palloc(CASH_BUFSZ + 2 - count)))
elog(ERROR, "Memory allocation failed, can't output cash", NULL);
strcpy(result, buf + count);
@@ -345,7 +345,7 @@ cash_pl(Cash *c1, Cash *c2)
if (!PointerIsValid(c1) || !PointerIsValid(c2))
return (NULL);
- if (!PointerIsValid(result = PALLOCTYPE(Cash)))
+ if (!PointerIsValid(result = palloc(sizeof(Cash))))
elog(ERROR, "Memory allocation failed, can't add cash", NULL);
*result = (*c1 + *c2);
@@ -365,7 +365,7 @@ cash_mi(Cash *c1, Cash *c2)
if (!PointerIsValid(c1) || !PointerIsValid(c2))
return (NULL);
- if (!PointerIsValid(result = PALLOCTYPE(Cash)))
+ if (!PointerIsValid(result = palloc(sizeof(Cash))))
elog(ERROR, "Memory allocation failed, can't subtract cash", NULL);
*result = (*c1 - *c2);
@@ -385,7 +385,7 @@ cash_mul_flt8(Cash *c, float8 *f)
if (!PointerIsValid(f) || !PointerIsValid(c))
return (NULL);
- if (!PointerIsValid(result = PALLOCTYPE(Cash)))
+ if (!PointerIsValid(result = palloc(sizeof(Cash))))
elog(ERROR, "Memory allocation failed, can't multiply cash", NULL);
*result = ((*f) * (*c));
@@ -418,7 +418,7 @@ cash_div_flt8(Cash *c, float8 *f)
if (!PointerIsValid(f) || !PointerIsValid(c))
return (NULL);
- if (!PointerIsValid(result = PALLOCTYPE(Cash)))
+ if (!PointerIsValid(result = palloc(sizeof(Cash))))
elog(ERROR, "Memory allocation failed, can't divide cash", NULL);
if (*f == 0.0)
@@ -440,7 +440,7 @@ cash_mul_flt4(Cash *c, float4 *f)
if (!PointerIsValid(f) || !PointerIsValid(c))
return (NULL);
- if (!PointerIsValid(result = PALLOCTYPE(Cash)))
+ if (!PointerIsValid(result = palloc(sizeof(Cash))))
elog(ERROR, "Memory allocation failed, can't multiply cash", NULL);
*result = ((*f) * (*c));
@@ -473,7 +473,7 @@ cash_div_flt4(Cash *c, float4 *f)
if (!PointerIsValid(f) || !PointerIsValid(c))
return (NULL);
- if (!PointerIsValid(result = PALLOCTYPE(Cash)))
+ if (!PointerIsValid(result = palloc(sizeof(Cash))))
elog(ERROR, "Memory allocation failed, can't divide cash", NULL);
if (*f == 0.0)
@@ -496,7 +496,7 @@ cash_mul_int4(Cash *c, int4 i)
if (!PointerIsValid(c))
return (NULL);
- if (!PointerIsValid(result = PALLOCTYPE(Cash)))
+ if (!PointerIsValid(result = palloc(sizeof(Cash))))
elog(ERROR, "Memory allocation failed, can't multiply cash", NULL);
*result = ((i) * (*c));
@@ -529,7 +529,7 @@ cash_div_int4(Cash *c, int4 i)
if (!PointerIsValid(c))
return (NULL);
- if (!PointerIsValid(result = PALLOCTYPE(Cash)))
+ if (!PointerIsValid(result = palloc(sizeof(Cash))))
elog(ERROR, "Memory allocation failed, can't divide cash", NULL);
if (i == 0)
@@ -552,7 +552,7 @@ cash_mul_int2(Cash *c, int2 s)
if (!PointerIsValid(c))
return (NULL);
- if (!PointerIsValid(result = PALLOCTYPE(Cash)))
+ if (!PointerIsValid(result = palloc(sizeof(Cash))))
elog(ERROR, "Memory allocation failed, can't multiply cash", NULL);
*result = ((s) * (*c));
@@ -585,7 +585,7 @@ cash_div_int2(Cash *c, int2 s)
if (!PointerIsValid(c))
return (NULL);
- if (!PointerIsValid(result = PALLOCTYPE(Cash)))
+ if (!PointerIsValid(result = palloc(sizeof(Cash))))
elog(ERROR, "Memory allocation failed, can't divide cash", NULL);
if (s == 0)
@@ -608,7 +608,7 @@ cashlarger(Cash *c1, Cash *c2)
if (!PointerIsValid(c1) || !PointerIsValid(c2))
return (NULL);
- if (!PointerIsValid(result = PALLOCTYPE(Cash)))
+ if (!PointerIsValid(result = palloc(sizeof(Cash))))
elog(ERROR, "Memory allocation failed, can't return larger cash", NULL);
*result = ((*c1 > *c2) ? *c1 : *c2);
@@ -628,7 +628,7 @@ cashsmaller(Cash *c1, Cash *c2)
if (!PointerIsValid(c1) || !PointerIsValid(c2))
return (NULL);
- if (!PointerIsValid(result = PALLOCTYPE(Cash)))
+ if (!PointerIsValid(result = palloc(sizeof(Cash))))
elog(ERROR, "Memory allocation failed, can't return smaller cash", NULL);
*result = ((*c1 < *c2) ? *c1 : *c2);