Esempio n. 1
0
int64_t lzbench_lzo1a_decompress(char *inbuf, size_t insize, char *outbuf, size_t outsize, size_t level, size_t, char*)
{
	lzo_uint decomplen = 0;

    if (lzo1a_decompress((uint8_t*)inbuf, insize, (uint8_t*)outbuf, &decomplen, NULL) != LZO_E_OK) return 0;

	return decomplen; 
}
Esempio n. 2
0
compr *lzo_decompress(unsigned char *buf, int buflen)
{
    int r;
    lzo_bytep in;
    lzo_bytep out;
    lzo_bytep wrkmem;
    lzo_uint out_len = 0;
    lzo_uint in_len = 0;
    compr *retdata;

    FUNC;

    pthread_mutex_lock(&lzo_mutex);
    retdata = s_malloc(sizeof(compr));
 
    in_len = buflen-1;
    in = (lzo_bytep) &buf[1];
    out = (lzo_bytep) lzo_malloc(BLKSIZE);
    wrkmem = (lzo_bytep) lzo_malloc(LZO1A_MEM_COMPRESS);        //FASTER
    if (in == NULL || out == NULL || wrkmem == NULL) {
        LFATAL("out of memory\n");
        exit(3);
    }

    r = lzo1a_decompress(in, in_len, out, &out_len, NULL);
    if (r != LZO_E_OK) {
        /* this should NEVER happen */
        LFATAL("internal error - decompression failed: %d\n", r);
        exit(22);
    }

    retdata->data = s_malloc(out_len);
    retdata->size = out_len;
    memcpy(retdata->data, out, out_len);
    lzo_free(wrkmem);
    lzo_free(out);
    pthread_mutex_unlock(&lzo_mutex);
    return retdata;
}