src/map.c

Sun, 21 May 2023 14:40:05 +0200

author
Mike Becker <universe@uap-core.de>
date
Sun, 21 May 2023 14:40:05 +0200
changeset 707
87eb4bdb2d0e
parent 706
8c6edaccaef1
child 709
1e8ba59e7911
permissions
-rw-r--r--

fix rehash not valid for non-hash-maps

universe@706 1 /*
universe@706 2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
universe@706 3 *
universe@706 4 * Copyright 2023 Mike Becker, Olaf Wintermann All rights reserved.
universe@706 5 *
universe@706 6 * Redistribution and use in source and binary forms, with or without
universe@706 7 * modification, are permitted provided that the following conditions are met:
universe@706 8 *
universe@706 9 * 1. Redistributions of source code must retain the above copyright
universe@706 10 * notice, this list of conditions and the following disclaimer.
universe@706 11 *
universe@706 12 * 2. Redistributions in binary form must reproduce the above copyright
universe@706 13 * notice, this list of conditions and the following disclaimer in the
universe@706 14 * documentation and/or other materials provided with the distribution.
universe@706 15 *
universe@706 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
universe@706 17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
universe@706 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
universe@706 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
universe@706 20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
universe@706 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
universe@706 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
universe@706 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
universe@706 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
universe@706 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
universe@706 26 * POSSIBILITY OF SUCH DAMAGE.
universe@706 27 */
universe@706 28
universe@706 29 #include "cx/map.h"
universe@706 30
universe@706 31 // <editor-fold desc="empty map implementation">
universe@706 32
universe@706 33 static void cx_empty_map_noop(__attribute__((__unused__)) CxMap *map) {
universe@706 34 // this is a noop, but MUST be implemented
universe@706 35 }
universe@706 36
universe@706 37 static void *cx_empty_map_get(
universe@706 38 __attribute__((__unused__)) CxMap const *map,
universe@706 39 __attribute__((__unused__)) CxHashKey key
universe@706 40 ) {
universe@706 41 return NULL;
universe@706 42 }
universe@706 43
universe@706 44 static bool cx_empty_map_iter_valid(__attribute__((__unused__)) void const *iter) {
universe@706 45 return false;
universe@706 46 }
universe@706 47
universe@706 48 static CxIterator cx_empty_map_iterator(struct cx_map_s const *map) {
universe@706 49 CxIterator iter = {0};
universe@706 50 iter.src_handle = map;
universe@706 51 iter.base.valid = cx_empty_map_iter_valid;
universe@706 52 return iter;
universe@706 53 }
universe@706 54
universe@706 55 static CxMutIterator cx_empty_map_miterator(struct cx_map_s *map) {
universe@706 56 CxMutIterator iter = {0};
universe@706 57 iter.src_handle = map;
universe@706 58 iter.base.valid = cx_empty_map_iter_valid;
universe@706 59 return iter;
universe@706 60 }
universe@706 61
universe@706 62 static struct cx_map_class_s cx_empty_map_class = {
universe@706 63 cx_empty_map_noop,
universe@706 64 cx_empty_map_noop,
universe@706 65 NULL,
universe@706 66 cx_empty_map_get,
universe@706 67 NULL,
universe@706 68 cx_empty_map_iterator,
universe@706 69 cx_empty_map_iterator,
universe@706 70 cx_empty_map_iterator,
universe@706 71 cx_empty_map_miterator,
universe@706 72 cx_empty_map_miterator,
universe@706 73 cx_empty_map_miterator,
universe@706 74 };
universe@706 75
universe@706 76 CxMap cx_empty_map = {
universe@706 77 NULL,
universe@706 78 NULL,
universe@706 79 0,
universe@706 80 0,
universe@706 81 NULL,
universe@706 82 NULL,
universe@706 83 NULL,
universe@706 84 false,
universe@706 85 &cx_empty_map_class
universe@706 86 };
universe@706 87
universe@706 88 CxMap * const cxEmptyMap = &cx_empty_map;
universe@706 89
universe@706 90 // </editor-fold>

mercurial