diff options
| author | Bruce Momjian <bruce@momjian.us> | 2002-11-10 07:25:14 +0000 |
|---|---|---|
| committer | Bruce Momjian <bruce@momjian.us> | 2002-11-10 07:25:14 +0000 |
| commit | 8fee9615ccdfb7ed99de3dfe0d964952ed45d978 (patch) | |
| tree | b13cf68a8e97d5e89a106fd7da9c3b524ad7a8c2 /src/backend/utils/adt | |
| parent | 78822b328c2907accf590d5473a0508ea3ee07a5 (diff) | |
| download | postgresql-8fee9615ccdfb7ed99de3dfe0d964952ed45d978.tar.gz | |
Merge palloc()/MemSet(0) calls into a single palloc0() call.
Diffstat (limited to 'src/backend/utils/adt')
| -rw-r--r-- | src/backend/utils/adt/acl.c | 5 | ||||
| -rw-r--r-- | src/backend/utils/adt/arrayfuncs.c | 19 | ||||
| -rw-r--r-- | src/backend/utils/adt/geo_ops.c | 9 | ||||
| -rw-r--r-- | src/backend/utils/adt/network.c | 14 | ||||
| -rw-r--r-- | src/backend/utils/adt/varbit.c | 11 |
5 files changed, 20 insertions, 38 deletions
diff --git a/src/backend/utils/adt/acl.c b/src/backend/utils/adt/acl.c index ffcb6ee891..2275cc8cb2 100644 --- a/src/backend/utils/adt/acl.c +++ b/src/backend/utils/adt/acl.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.80 2002/09/24 23:14:25 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.81 2002/11/10 07:25:14 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -248,8 +248,7 @@ makeacl(int n) if (n < 0) elog(ERROR, "makeacl: invalid size: %d", n); size = ACL_N_SIZE(n); - new_acl = (Acl *) palloc(size); - MemSet((char *) new_acl, 0, size); + new_acl = (Acl *) palloc0(size); new_acl->size = size; new_acl->ndim = 1; new_acl->flags = 0; diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/arrayfuncs.c index 1b6a4d9e0f..3340449b1a 100644 --- a/src/backend/utils/adt/arrayfuncs.c +++ b/src/backend/utils/adt/arrayfuncs.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.82 2002/11/08 17:27:02 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.83 2002/11/10 07:25:14 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -235,8 +235,7 @@ array_in(PG_FUNCTION_ARGS) if (nitems == 0) { /* Return empty array */ - retval = (ArrayType *) palloc(sizeof(ArrayType)); - MemSet(retval, 0, sizeof(ArrayType)); + retval = (ArrayType *) palloc0(sizeof(ArrayType)); retval->size = sizeof(ArrayType); retval->elemtype = element_type; PG_RETURN_ARRAYTYPE_P(retval); @@ -249,8 +248,7 @@ array_in(PG_FUNCTION_ARGS) typmod, typdelim, typlen, typbyval, typalign, &nbytes); nbytes += ARR_OVERHEAD(ndim); - retval = (ArrayType *) palloc(nbytes); - MemSet(retval, 0, nbytes); + retval = (ArrayType *) palloc0(nbytes); retval->size = nbytes; retval->ndim = ndim; retval->elemtype = element_type; @@ -397,8 +395,7 @@ ReadArrayStr(char *arrayStr, prod[MAXDIM]; mda_get_prod(ndim, dim, prod); - values = (Datum *) palloc(nitems * sizeof(Datum)); - MemSet(values, 0, nitems * sizeof(Datum)); + values = (Datum *) palloc0(nitems * sizeof(Datum)); MemSet(indx, 0, sizeof(indx)); /* read array enclosed within {} */ @@ -514,10 +511,7 @@ ReadArrayStr(char *arrayStr, if (!typbyval) for (i = 0; i < nitems; i++) if (values[i] == (Datum) 0) - { - values[i] = PointerGetDatum(palloc(typlen)); - MemSet(DatumGetPointer(values[i]), 0, typlen); - } + values[i] = PointerGetDatum(palloc0(typlen)); } else { @@ -1593,8 +1587,7 @@ array_map(FunctionCallInfo fcinfo, Oid inpType, Oid retType) /* Allocate and initialize the result array */ nbytes += ARR_OVERHEAD(ndim); - result = (ArrayType *) palloc(nbytes); - MemSet(result, 0, nbytes); + result = (ArrayType *) palloc0(nbytes); result->size = nbytes; result->ndim = ndim; diff --git a/src/backend/utils/adt/geo_ops.c b/src/backend/utils/adt/geo_ops.c index 513b6c1321..f39cfab1b1 100644 --- a/src/backend/utils/adt/geo_ops.c +++ b/src/backend/utils/adt/geo_ops.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_ops.c,v 1.68 2002/11/08 18:32:47 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_ops.c,v 1.69 2002/11/10 07:25:14 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -3130,9 +3130,8 @@ poly_in(PG_FUNCTION_ARGS) elog(ERROR, "Bad polygon external representation '%s'", str); size = offsetof(POLYGON, p[0]) +sizeof(poly->p[0]) * npts; - poly = (POLYGON *) palloc(size); + poly = (POLYGON *) palloc0(size); /* zero any holes */ - MemSet((char *) poly, 0, size); /* zero any holes */ poly->size = size; poly->npts = npts; @@ -4452,9 +4451,7 @@ circle_poly(PG_FUNCTION_ARGS) if (base_size / npts != sizeof(poly->p[0]) || size <= base_size) elog(ERROR, "too many points requested"); - poly = (POLYGON *) palloc(size); - - MemSet(poly, 0, size); /* zero any holes */ + poly = (POLYGON *) palloc0(size); /* zero any holes */ poly->size = size; poly->npts = npts; diff --git a/src/backend/utils/adt/network.c b/src/backend/utils/adt/network.c index 31fb9c1b87..429bac59e9 100644 --- a/src/backend/utils/adt/network.c +++ b/src/backend/utils/adt/network.c @@ -3,7 +3,7 @@ * is for IP V4 CIDR notation, but prepared for V6: just * add the necessary bits where the comments indicate. * - * $Header: /cvsroot/pgsql/src/backend/utils/adt/network.c,v 1.35 2002/09/02 02:47:04 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/network.c,v 1.36 2002/11/10 07:25:14 momjian Exp $ * * Jon Postel RIP 16 Oct 1998 */ @@ -51,9 +51,8 @@ network_in(char *src, int type) int bits; inet *dst; - dst = (inet *) palloc(VARHDRSZ + sizeof(inet_struct)); /* make sure any unused bits in a CIDR value are zeroed */ - MemSet(dst, 0, VARHDRSZ + sizeof(inet_struct)); + dst = (inet *) palloc0(VARHDRSZ + sizeof(inet_struct)); /* First, try for an IP V4 address: */ ip_family(dst) = AF_INET; @@ -494,9 +493,8 @@ network_broadcast(PG_FUNCTION_ARGS) inet *ip = PG_GETARG_INET_P(0); inet *dst; - dst = (inet *) palloc(VARHDRSZ + sizeof(inet_struct)); /* make sure any unused bits are zeroed */ - MemSet(dst, 0, VARHDRSZ + sizeof(inet_struct)); + dst = (inet *) palloc0(VARHDRSZ + sizeof(inet_struct)); if (ip_family(ip) == AF_INET) { @@ -534,9 +532,8 @@ network_network(PG_FUNCTION_ARGS) inet *ip = PG_GETARG_INET_P(0); inet *dst; - dst = (inet *) palloc(VARHDRSZ + sizeof(inet_struct)); /* make sure any unused bits are zeroed */ - MemSet(dst, 0, VARHDRSZ + sizeof(inet_struct)); + dst = (inet *) palloc0(VARHDRSZ + sizeof(inet_struct)); if (ip_family(ip) == AF_INET) { @@ -574,9 +571,8 @@ network_netmask(PG_FUNCTION_ARGS) inet *ip = PG_GETARG_INET_P(0); inet *dst; - dst = (inet *) palloc(VARHDRSZ + sizeof(inet_struct)); /* make sure any unused bits are zeroed */ - MemSet(dst, 0, VARHDRSZ + sizeof(inet_struct)); + dst = (inet *) palloc0(VARHDRSZ + sizeof(inet_struct)); if (ip_family(ip) == AF_INET) { diff --git a/src/backend/utils/adt/varbit.c b/src/backend/utils/adt/varbit.c index 715a99863f..7d98491d77 100644 --- a/src/backend/utils/adt/varbit.c +++ b/src/backend/utils/adt/varbit.c @@ -9,7 +9,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/varbit.c,v 1.26 2002/09/18 21:35:23 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/varbit.c,v 1.27 2002/11/10 07:25:14 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -107,9 +107,8 @@ bit_in(PG_FUNCTION_ARGS) bitlen, atttypmod); len = VARBITTOTALLEN(atttypmod); - result = (VarBit *) palloc(len); /* set to 0 so that *r is always initialised and string is zero-padded */ - MemSet(result, 0, len); + result = (VarBit *) palloc0(len); VARATT_SIZEP(result) = len; VARBITLEN(result) = atttypmod; @@ -232,9 +231,8 @@ bit(PG_FUNCTION_ARGS) VARBITLEN(arg), len); rlen = VARBITTOTALLEN(len); - result = (VarBit *) palloc(rlen); /* set to 0 so that string is zero-padded */ - MemSet(result, 0, rlen); + result = (VarBit *) palloc0(rlen); VARATT_SIZEP(result) = rlen; VARBITLEN(result) = len; @@ -316,9 +314,8 @@ varbit_in(PG_FUNCTION_ARGS) atttypmod); len = VARBITTOTALLEN(bitlen); - result = (VarBit *) palloc(len); /* set to 0 so that *r is always initialised and string is zero-padded */ - MemSet(result, 0, len); + result = (VarBit *) palloc0(len); VARATT_SIZEP(result) = len; VARBITLEN(result) = Min(bitlen, atttypmod); |
