universe@39: /* universe@39: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. universe@39: * universe@39: * Copyright 2015 Olaf Wintermann. All rights reserved. universe@39: * universe@39: * Redistribution and use in source and binary forms, with or without universe@39: * modification, are permitted provided that the following conditions are met: universe@39: * universe@39: * 1. Redistributions of source code must retain the above copyright universe@39: * notice, this list of conditions and the following disclaimer. universe@39: * universe@39: * 2. Redistributions in binary form must reproduce the above copyright universe@39: * notice, this list of conditions and the following disclaimer in the universe@39: * documentation and/or other materials provided with the distribution. universe@39: * universe@39: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" universe@39: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE universe@39: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE universe@39: * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE universe@39: * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR universe@39: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF universe@39: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS universe@39: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN universe@39: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) universe@39: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE universe@39: * POSSIBILITY OF SUCH DAMAGE. universe@39: */ universe@39: universe@39: #include universe@39: #include "allocator.h" universe@39: universe@39: UcxAllocator default_allocator = { universe@39: NULL, universe@39: ucx_default_malloc, universe@39: ucx_default_calloc, universe@39: ucx_default_realloc, universe@39: ucx_default_free universe@39: }; universe@39: universe@39: UcxAllocator *ucx_default_allocator() { universe@39: UcxAllocator *allocator = &default_allocator; universe@39: return allocator; universe@39: } universe@39: universe@39: void *ucx_default_malloc(void *ignore, size_t n) { universe@39: return malloc(n); universe@39: } universe@39: universe@39: void *ucx_default_calloc(void *ignore, size_t n, size_t size) { universe@39: return calloc(n, size); universe@39: } universe@39: universe@39: void *ucx_default_realloc(void *ignore, void *data, size_t n) { universe@39: return realloc(data, n); universe@39: } universe@39: universe@39: void ucx_default_free(void *ignore, void *data) { universe@39: free(data); universe@39: }