ucx/mempool.c

changeset 335
c1bc13faadaa
parent 314
8722a668fb2a
child 505
481802342fdf
equal deleted inserted replaced
334:5f80c5d0e87f 335:c1bc13faadaa
1 /* 1 /*
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3 * 3 *
4 * Copyright 2016 Olaf Wintermann. All rights reserved. 4 * Copyright 2017 Mike Becker, Olaf Wintermann All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met: 7 * modification, are permitted provided that the following conditions are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE. 26 * POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29 #include "ucx/mempool.h"
30
29 #include <stdlib.h> 31 #include <stdlib.h>
30 #include <string.h> 32 #include <string.h>
31 #include <stdio.h> 33 #include <stdio.h>
32 #ifdef __cplusplus 34 #ifdef __cplusplus
33 #define __STDC_FORMAT_MACROS 35 #define __STDC_FORMAT_MACROS
34 #endif 36 #endif
35 #include <inttypes.h> 37 #include <inttypes.h>
36
37 #include "mempool.h"
38 38
39 /** Capsule for destructible memory chunks. */ 39 /** Capsule for destructible memory chunks. */
40 typedef struct { 40 typedef struct {
41 /** The destructor for the memory chunk. */ 41 /** The destructor for the memory chunk. */
42 ucx_destructor destructor; 42 ucx_destructor destructor;
54 ucx_destructor destructor; 54 ucx_destructor destructor;
55 /** A pointer to the data. */ 55 /** A pointer to the data. */
56 void *ptr; 56 void *ptr;
57 } ucx_regdestr; 57 } ucx_regdestr;
58 58
59 UCX_EXTERN void ucx_mempool_shared_destr(void* ptr) { 59 #ifdef __cplusplus
60 extern "C"
61 #endif
62 void ucx_mempool_shared_destr(void* ptr) {
60 ucx_regdestr *rd = (ucx_regdestr*)ptr; 63 ucx_regdestr *rd = (ucx_regdestr*)ptr;
61 rd->destructor(rd->ptr); 64 rd->destructor(rd->ptr);
62 } 65 }
63 66
64 UcxMempool *ucx_mempool_new(size_t n) { 67 UcxMempool *ucx_mempool_new(size_t n) {

mercurial