X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;ds=sidebyside;f=src%2Fwsr88ddec.c;h=3771ba6d098a6265105d4172df5e467997b4584a;hb=48967383a153c13fdcab093f1dee938be909414f;hp=50152722da65859c4e4829a39acc9abf504acb59;hpb=7ea4985dd27c1d11398af41d17745d7b75c6f4d7;p=aweather
diff --git a/src/wsr88ddec.c b/src/wsr88ddec.c
index 5015272..3771ba6 100644
--- a/src/wsr88ddec.c
+++ b/src/wsr88ddec.c
@@ -15,25 +15,19 @@
* along with this program. If not, see .
*/
-#include
-#include
-#include
-#include
-#include
+#include
#include
-#define debug(...) fprintf(stderr, __VA_ARGS__);
-
char *bunzip2(char *input, int input_len, int *output_len)
{
- bz_stream *stream = calloc(1, sizeof(bz_stream));
+ bz_stream *stream = g_new0(bz_stream, 1);
switch (BZ2_bzDecompressInit(stream, 0, 0)) {
- case BZ_CONFIG_ERROR: err(1, "the library has been mis-compiled");
- case BZ_PARAM_ERROR: err(1, "Parameter error");
- case BZ_MEM_ERROR: err(1, "insufficient memory is available");
- //case BZ_OK: debug("success\n"); break;
- //default: debug("unknown\n"); break;
+ case BZ_CONFIG_ERROR: g_error("the library has been mis-compiled");
+ case BZ_PARAM_ERROR: g_error("Parameter error");
+ case BZ_MEM_ERROR: g_error("insufficient memory is available");
+ //case BZ_OK: g_debug("success\n"); break;
+ //default: g_debug("unknown\n"); break;
}
int status;
@@ -44,11 +38,11 @@ char *bunzip2(char *input, int input_len, int *output_len)
stream->next_in = input + stream->total_in_lo32;
stream->avail_in = input_len - stream->total_in_lo32;
output_size *= 2;
- output = realloc(output, output_size);
- //debug("alloc %d\n", output_size);
+ output = g_realloc(output, output_size);
+ //g_debug("alloc %d\n", output_size);
stream->next_out = output + stream->total_out_lo32;
stream->avail_out = output_size - stream->total_out_lo32;
- //debug("decompressing..\n"
+ //g_debug("decompressing..\n"
// " next_in = %p\n"
// " avail_in = %u\n"
// " next_out = %p\n"
@@ -59,7 +53,7 @@ char *bunzip2(char *input, int input_len, int *output_len)
// stream->avail_out);
} while ((status = BZ2_bzDecompress(stream)) == BZ_OK && output_size < 1024*1024);
- // debug("done with status %d = %d\n", status, BZ_STREAM_END);
+ // g_debug("done with status %d = %d\n", status, BZ_STREAM_END);
*output_len = stream->total_out_lo32;
BZ2_bzDecompressEnd(stream);
@@ -69,48 +63,48 @@ char *bunzip2(char *input, int input_len, int *output_len)
int main(int argc, char **argv)
{
if (argc != 3) {
- printf("usage: %s