mem.c

来自「About: hamsterdb is a database engine w」· C语言 代码 · 共 64 行

C
64
字号
/** * Copyright (C) 2005-2007 Christoph Rupp (chris@crupp.de). * All rights reserved. See file LICENSE for licence and copyright * information. * */#include "config.h"#include <string.h>#ifdef HAVE_MALLOC_H#  include <malloc.h>#else#  include <stdlib.h>#endif#include "mem.h"#include "error.h"void *alloc_impl(mem_allocator_t *self, const char *file, int line, ham_u32_t size){    (void)self;    (void)file;    (void)line;    return (malloc(size));}void free_impl(mem_allocator_t *self, const char *file, int line, void *ptr){    (void)self;    (void)file;    (void)line;    ham_assert(ptr, ("freeing NULL pointer in line %s:%d", file, line))     free(ptr);}void close_impl(mem_allocator_t *self){    free(self);}mem_allocator_t *ham_default_allocator_new(void){    mem_allocator_t *m;    m=(mem_allocator_t *)malloc(sizeof(*m));    if (!m)        return (0);    memset(m, 0, sizeof(*m));    m->alloc=alloc_impl;    m->free =free_impl;    m->close=close_impl;         return (m);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?