aboutsummaryrefslogtreecommitdiff
path: root/contrib/pgcrypto/pgp-compress.c
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2020-09-25 10:25:55 +0900
committerMichael Paquier <michael@paquier.xyz>2020-09-25 10:25:55 +0900
commitca7f8e2b86e5f15a40b67e6199d714f45a467ff1 (patch)
tree19c94a35cb8ff4902d4b4f7b477ace69e1d34a33 /contrib/pgcrypto/pgp-compress.c
parenta45bc8a4f6495072bc48ad40a5aa0304979114f7 (diff)
downloadpostgresql-ca7f8e2b86e5f15a40b67e6199d714f45a467ff1.tar.gz
postgresql-ca7f8e2b86e5f15a40b67e6199d714f45a467ff1.zip
Remove custom memory allocation layer in pgcrypto
PX_OWN_ALLOC was intended as a way to disable the use of palloc(), and over the time new palloc() or equivalent calls have been added like in 32984d8, making this extra layer losing its original purpose. This simplifies on the way some code paths to use palloc0() rather than palloc() followed by memset(0). Author: Daniel Gustafsson Discussion: https://postgr.es/m/A5BFAA1A-B2E8-4CBC-895E-7B1B9475A527@yesql.se
Diffstat (limited to 'contrib/pgcrypto/pgp-compress.c')
-rw-r--r--contrib/pgcrypto/pgp-compress.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/contrib/pgcrypto/pgp-compress.c b/contrib/pgcrypto/pgp-compress.c
index 3636a662b07..7e8ddba1873 100644
--- a/contrib/pgcrypto/pgp-compress.c
+++ b/contrib/pgcrypto/pgp-compress.c
@@ -57,13 +57,13 @@ struct ZipStat
static void *
z_alloc(void *priv, unsigned n_items, unsigned item_len)
{
- return px_alloc(n_items * item_len);
+ return palloc(n_items * item_len);
}
static void
z_free(void *priv, void *addr)
{
- px_free(addr);
+ pfree(addr);
}
static int
@@ -80,8 +80,7 @@ compress_init(PushFilter *next, void *init_arg, void **priv_p)
/*
* init
*/
- st = px_alloc(sizeof(*st));
- memset(st, 0, sizeof(*st));
+ st = palloc0(sizeof(*st));
st->buf_len = ZIP_OUT_BUF;
st->stream.zalloc = z_alloc;
st->stream.zfree = z_free;
@@ -93,7 +92,7 @@ compress_init(PushFilter *next, void *init_arg, void **priv_p)
res = deflateInit(&st->stream, ctx->compress_level);
if (res != Z_OK)
{
- px_free(st);
+ pfree(st);
return PXE_PGP_COMPRESSION_ERROR;
}
*priv_p = st;
@@ -174,7 +173,7 @@ compress_free(void *priv)
deflateEnd(&st->stream);
px_memset(st, 0, sizeof(*st));
- px_free(st);
+ pfree(st);
}
static const PushFilterOps
@@ -212,8 +211,7 @@ decompress_init(void **priv_p, void *arg, PullFilter *src)
&& ctx->compress_algo != PGP_COMPR_ZIP)
return PXE_PGP_UNSUPPORTED_COMPR;
- dec = px_alloc(sizeof(*dec));
- memset(dec, 0, sizeof(*dec));
+ dec = palloc0(sizeof(*dec));
dec->buf_len = ZIP_OUT_BUF;
*priv_p = dec;
@@ -226,7 +224,7 @@ decompress_init(void **priv_p, void *arg, PullFilter *src)
res = inflateInit(&dec->stream);
if (res != Z_OK)
{
- px_free(dec);
+ pfree(dec);
px_debug("decompress_init: inflateInit error");
return PXE_PGP_COMPRESSION_ERROR;
}
@@ -318,7 +316,7 @@ decompress_free(void *priv)
inflateEnd(&dec->stream);
px_memset(dec, 0, sizeof(*dec));
- px_free(dec);
+ pfree(dec);
}
static const PullFilterOps