Changeset View
Changeset View
Standalone View
Standalone View
sys/contrib/xz-embedded/freebsd/xz_malloc.c
Show All 20 Lines | |||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
* SUCH DAMAGE. | * SUCH DAMAGE. | ||||
*/ | */ | ||||
#include <sys/malloc.h> | #include <sys/malloc.h> | ||||
#include <sys/kernel.h> | #include <sys/kernel.h> | ||||
#include <sys/module.h> | |||||
#include "xz.h" | |||||
#include "xz_malloc.h" | #include "xz_malloc.h" | ||||
/* Wraper for XZ decompressor memmory pool */ | /* Wraper for XZ decompressor memmory pool */ | ||||
static MALLOC_DEFINE(XZ_DEC, "XZ_DEC", "XZ decompressor data"); | static MALLOC_DEFINE(XZ_DEC, "XZ_DEC", "XZ decompressor data"); | ||||
void * | void * | ||||
xz_malloc(unsigned long size) | xz_malloc(unsigned long size) | ||||
{ | { | ||||
void *addr; | void *addr; | ||||
addr = malloc(size, XZ_DEC, M_NOWAIT); | addr = malloc(size, XZ_DEC, M_NOWAIT); | ||||
return (addr); | return (addr); | ||||
} | } | ||||
void | void | ||||
xz_free(void *addr) | xz_free(void *addr) | ||||
{ | { | ||||
free(addr, XZ_DEC); | free(addr, XZ_DEC); | ||||
} | } | ||||
static int | |||||
xz_module_event_handler(module_t mod, int what, void *arg) | |||||
sobomax: I don't think this function and all things below (moduledata_t xz_moduledata etc) belongs to… | |||||
Not Done Inline ActionsP.S. xz_mod.c (xz.c?) itself should probably live in the sys/dev/xz, like most other FreeBSD-specific device code. It is not contributed in any way and I don't think anyone but us would care to maintain it. sobomax: P.S. xz_mod.c (xz.c?) itself should probably live in the sys/dev/xz, like most other FreeBSD… | |||||
{ | |||||
int error; | |||||
switch (what) { | |||||
case MOD_LOAD: | |||||
#if XZ_INTERNAL_CRC32 | |||||
xz_crc32_init(); | |||||
#endif | |||||
#if XZ_INTERNAL_CRC64 | |||||
xz_crc64_init(); | |||||
#endif | |||||
error = 0; | |||||
break; | |||||
case MOD_UNLOAD: | |||||
error = 0; | |||||
break; | |||||
default: | |||||
error = EOPNOTSUPP; | |||||
break; | |||||
} | |||||
return (error); | |||||
} | |||||
static moduledata_t xz_moduledata = { | |||||
"xz", | |||||
xz_module_event_handler, | |||||
NULL | |||||
}; | |||||
DECLARE_MODULE(xz, xz_moduledata, SI_SUB_INIT_IF, SI_ORDER_ANY); | |||||
MODULE_VERSION(xz, 1); |
I don't think this function and all things below (moduledata_t xz_moduledata etc) belongs to the xz_malloc.c. It clearly has nothing to do with "malloc". I'd suggest something like xz_mod.c or something.