Skip to content

Commit

Permalink
Move init closer to use point
Browse files Browse the repository at this point in the history
  • Loading branch information
pramsey committed Nov 16, 2019
1 parent 35f9cca commit 33b640b
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions pg_gzip.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ Datum pg_gzip(PG_FUNCTION_ARGS)
if (compression_level < -1 || compression_level > 9)
elog(ERROR, "invalid compression level: %d", compression_level);

initStringInfo(&si);

/* Prepare the z_stream state */
zs.zalloc = pg_gzip_alloc;
zs.zfree = pg_gzip_free;
Expand All @@ -113,6 +111,7 @@ Datum pg_gzip(PG_FUNCTION_ARGS)
zs.avail_out = ZCHUNK;

/* Compress until deflate stops returning output */
initStringInfo(&si);
zs_rv = Z_OK;
while (zs_rv == Z_OK)
{
Expand Down Expand Up @@ -153,8 +152,6 @@ Datum pg_gunzip(PG_FUNCTION_ARGS)
uint8* in = (uint8*)(VARDATA(compressed));
size_t in_size = VARSIZE_ANY_EXHDR(compressed);

initStringInfo(&si);

/* Prepare the z_stream state */
zs.zalloc = pg_gzip_alloc;
zs.zfree = pg_gzip_free;
Expand All @@ -170,6 +167,7 @@ Datum pg_gunzip(PG_FUNCTION_ARGS)
zs.avail_out = ZCHUNK;

/* Decompress until inflate stops returning output */
initStringInfo(&si);
zs_rv = Z_OK;
while (zs_rv == Z_OK)
{
Expand Down

0 comments on commit 33b640b

Please sign in to comment.