src/ucx/allocator.c

Tue, 23 Aug 2016 13:49:38 +0200

author
Mike Becker <universe@uap-core.de>
date
Tue, 23 Aug 2016 13:49:38 +0200
changeset 39
ac35daceb24c
permissions
-rw-r--r--

adds UCX + changes how the input file is read (uses an consecutive memory area now)

universe@39 1 /*
universe@39 2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
universe@39 3 *
universe@39 4 * Copyright 2015 Olaf Wintermann. All rights reserved.
universe@39 5 *
universe@39 6 * Redistribution and use in source and binary forms, with or without
universe@39 7 * modification, are permitted provided that the following conditions are met:
universe@39 8 *
universe@39 9 * 1. Redistributions of source code must retain the above copyright
universe@39 10 * notice, this list of conditions and the following disclaimer.
universe@39 11 *
universe@39 12 * 2. Redistributions in binary form must reproduce the above copyright
universe@39 13 * notice, this list of conditions and the following disclaimer in the
universe@39 14 * documentation and/or other materials provided with the distribution.
universe@39 15 *
universe@39 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
universe@39 17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
universe@39 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
universe@39 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
universe@39 20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
universe@39 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
universe@39 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
universe@39 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
universe@39 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
universe@39 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
universe@39 26 * POSSIBILITY OF SUCH DAMAGE.
universe@39 27 */
universe@39 28
universe@39 29 #include <stdlib.h>
universe@39 30 #include "allocator.h"
universe@39 31
universe@39 32 UcxAllocator default_allocator = {
universe@39 33 NULL,
universe@39 34 ucx_default_malloc,
universe@39 35 ucx_default_calloc,
universe@39 36 ucx_default_realloc,
universe@39 37 ucx_default_free
universe@39 38 };
universe@39 39
universe@39 40 UcxAllocator *ucx_default_allocator() {
universe@39 41 UcxAllocator *allocator = &default_allocator;
universe@39 42 return allocator;
universe@39 43 }
universe@39 44
universe@39 45 void *ucx_default_malloc(void *ignore, size_t n) {
universe@39 46 return malloc(n);
universe@39 47 }
universe@39 48
universe@39 49 void *ucx_default_calloc(void *ignore, size_t n, size_t size) {
universe@39 50 return calloc(n, size);
universe@39 51 }
universe@39 52
universe@39 53 void *ucx_default_realloc(void *ignore, void *data, size_t n) {
universe@39 54 return realloc(data, n);
universe@39 55 }
universe@39 56
universe@39 57 void ucx_default_free(void *ignore, void *data) {
universe@39 58 free(data);
universe@39 59 }

mercurial