Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v3.16-rc6 47 lines 1.1 kB view raw
1/* 2 * Copyright (C) 2014 Sergey Senozhatsky. 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 7 * 2 of the License, or (at your option) any later version. 8 */ 9 10#include <linux/kernel.h> 11#include <linux/slab.h> 12#include <linux/lzo.h> 13 14#include "zcomp_lzo.h" 15 16static void *lzo_create(void) 17{ 18 return kzalloc(LZO1X_MEM_COMPRESS, GFP_KERNEL); 19} 20 21static void lzo_destroy(void *private) 22{ 23 kfree(private); 24} 25 26static int lzo_compress(const unsigned char *src, unsigned char *dst, 27 size_t *dst_len, void *private) 28{ 29 int ret = lzo1x_1_compress(src, PAGE_SIZE, dst, dst_len, private); 30 return ret == LZO_E_OK ? 0 : ret; 31} 32 33static int lzo_decompress(const unsigned char *src, size_t src_len, 34 unsigned char *dst) 35{ 36 size_t dst_len = PAGE_SIZE; 37 int ret = lzo1x_decompress_safe(src, src_len, dst, &dst_len); 38 return ret == LZO_E_OK ? 0 : ret; 39} 40 41struct zcomp_backend zcomp_lzo = { 42 .compress = lzo_compress, 43 .decompress = lzo_decompress, 44 .create = lzo_create, 45 .destroy = lzo_destroy, 46 .name = "lzo", 47};