MCPcopy Create free account
hub / github.com/ElementsProject/lightning / unzlib

Function unzlib

common/decode_array.c:7–23  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5#include <zlib.h>
6
7static u8 *unzlib(const tal_t *ctx, const u8 *encoded, size_t len)
8{
9 /* http://www.zlib.net/zlib_tech.html gives 1032:1 as worst-case,
10 * which is 67632120 bytes for us. But they're not encoding zeroes,
11 * and each scid must be unique. So 1MB is far more reasonable. */
12 unsigned long unclen = 1024*1024;
13 int zerr;
14 u8 *unc = tal_arr(ctx, u8, unclen);
15
16 zerr = uncompress(unc, &unclen, encoded, len);
17 if (zerr != Z_OK)
18 return tal_free(unc);
19
20 /* Truncate and return. */
21 tal_resize(&unc, unclen);
22 return unc;
23}
24
25struct short_channel_id *decode_short_ids(const tal_t *ctx, const u8 *encoded)
26{

Callers 3

decode_short_idsFunction · 0.85
decode_scid_query_flagsFunction · 0.85

Calls 1

tal_freeFunction · 0.85

Tested by

no test coverage detected