ucx/allocator.h

changeset 225
a1a068c2c4ef
parent 192
1e51558b9d09
child 250
b7d1317b138e
equal deleted inserted replaced
224:f9ba63fc6a80 225:a1a068c2c4ef
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 2015 Olaf Wintermann. All rights reserved. 4 * Copyright 2016 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
26 * POSSIBILITY OF SUCH DAMAGE. 26 * POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 /** 28 /**
29 * Allocator for custom memory management. 29 * Allocator for custom memory management.
30 * 30 *
31 * An UCX allocator consists of a pointer to the memory area / pool and four 31 * A UCX allocator consists of a pointer to the memory area / pool and four
32 * function pointers to memory management functions operating on this memory 32 * function pointers to memory management functions operating on this memory
33 * area / pool. These functions shall behave equivalent to the standard libc 33 * area / pool. These functions shall behave equivalent to the standard libc
34 * functions <code>malloc(), calloc(), realloc()</code> and <code>free()</code>. 34 * functions <code>malloc(), calloc(), realloc()</code> and <code>free()</code>.
35 * 35 *
36 * The signature of the memory management functions is based on the signature 36 * The signature of the memory management functions is based on the signature
37 * of the respective libc function but each of them takes the pointer to the 37 * of the respective libc function but each of them takes the pointer to the
38 * memory area / pool as first argument. 38 * memory area / pool as first argument.
39 * 39 *
40 * As the pointer to the memory area / pool can be arbitrarily chosen, any data 40 * As the pointer to the memory area / pool can be arbitrarily chosen, any data
41 * can be provided to the memory management functions. An UcxMempool is just 41 * can be provided to the memory management functions. A UcxMempool is just
42 * one example. 42 * one example.
43 * 43 *
44 * @see mempool.h 44 * @see mempool.h
45 * @see UcxMap 45 * @see UcxMap
46 * 46 *
114 * 114 *
115 * The default allocator contains wrappers to the standard libc memory 115 * The default allocator contains wrappers to the standard libc memory
116 * management functions. Use this function to get a pointer to a globally 116 * management functions. Use this function to get a pointer to a globally
117 * available allocator. You may also define an own UcxAllocator by assigning 117 * available allocator. You may also define an own UcxAllocator by assigning
118 * #UCX_ALLOCATOR_DEFAULT to a variable and pass the address of this variable 118 * #UCX_ALLOCATOR_DEFAULT to a variable and pass the address of this variable
119 * to any function that takes an UcxAllocator as argument. Note that using 119 * to any function that takes a UcxAllocator as argument. Note that using
120 * this function is the recommended way of passing a default allocator, thus 120 * this function is the recommended way of passing a default allocator, thus
121 * it never runs out of scope. 121 * it never runs out of scope.
122 * 122 *
123 * @return a pointer to the default allocator 123 * @return a pointer to the default allocator
124 * 124 *

mercurial