ucx/mempool.h

changeset 124
80609f9675f1
parent 2
eeb50c534497
child 152
62921b370c60
equal deleted inserted replaced
123:55adc92e7c09 124:80609f9675f1
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 2013 Olaf Wintermann. All rights reserved. 4 * Copyright 2015 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
43 #include "allocator.h" 43 #include "allocator.h"
44 44
45 #ifdef __cplusplus 45 #ifdef __cplusplus
46 extern "C" { 46 extern "C" {
47 #endif 47 #endif
48
49 /**
50 * A function pointer to a destructor function.
51 * @see ucx_mempool_setdestr()
52 * @see ucx_mempool_regdestr()
53 */
54 typedef void(*ucx_destructor)(void*);
55 48
56 /** 49 /**
57 * UCX mempool structure. 50 * UCX mempool structure.
58 */ 51 */
59 typedef struct { 52 typedef struct {
119 */ 112 */
120 void *ucx_mempool_malloc(UcxMempool *pool, size_t n); 113 void *ucx_mempool_malloc(UcxMempool *pool, size_t n);
121 /** 114 /**
122 * Allocates a pooled memory array. 115 * Allocates a pooled memory array.
123 * 116 *
124 * The contents of the allocated memory is set to zero. 117 * The content of the allocated memory is set to zero.
125 * 118 *
126 * @param pool the memory pool 119 * @param pool the memory pool
127 * @param nelem amount of elements to allocate 120 * @param nelem amount of elements to allocate
128 * @param elsize amount of memory per element 121 * @param elsize amount of memory per element
129 * @return a pointer to the allocated memory 122 * @return a pointer to the allocated memory
140 * and exit the program with error code <code>EXIT_FAILURE</code>. 133 * and exit the program with error code <code>EXIT_FAILURE</code>.
141 * 134 *
142 * @param pool the memory pool 135 * @param pool the memory pool
143 * @param ptr a pointer to the memory that shall be reallocated 136 * @param ptr a pointer to the memory that shall be reallocated
144 * @param n the new size of the memory 137 * @param n the new size of the memory
145 * @return a pointer to the the location of the memory 138 * @return a pointer to the new location of the memory
146 * @see ucx_allocator_realloc() 139 * @see ucx_allocator_realloc()
147 */ 140 */
148 void *ucx_mempool_realloc(UcxMempool *pool, void *ptr, size_t n); 141 void *ucx_mempool_realloc(UcxMempool *pool, void *ptr, size_t n);
149 142
150 /** 143 /**

mercurial