| 5 | #include <zlib.h> |
| 6 | |
| 7 | static 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 | |
| 25 | struct short_channel_id *decode_short_ids(const tal_t *ctx, const u8 *encoded) |
| 26 | { |
no test coverage detected