mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
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
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user