blob: aa1a47f082e9c0efb3b0788d7f61b3d8e2023800 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
//
// Created by stefan on 18.06.20.
//
#ifndef BETRIEBSYSTEME_SLOTMAP_H
#define BETRIEBSYSTEME_SLOTMAP_H
#include <stdatomic.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdint.h>
typedef struct smNode {
atomic_intptr_t value;
} smEntry;
typedef struct smHeader {
smEntry *slab;
size_t size;
atomic_int count;
} smHeader;
typedef bool (*SearchFunction)(void const *);
smHeader smInit(smEntry * slab, size_t size);
int smInsert(smHeader * header, void * value);
void smDeleteValue(smHeader * header, void * value);
/**
* Returns a node whose value is accepted by the SearchFunction
* @param header The header of the slotmap to be searched
* @param func The search function, that will be applied to each element until one is found
* @return the Entry that was found
*/
smEntry *smFindEntry(smHeader const * header, SearchFunction func);
#endif // BETRIEBSYSTEME_SLOTMAP_H
|