MCPcopy Create free account
hub / github.com/RsyncProject/rsync / pool_create

Function pool_create

lib/pool_alloc.c:47–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45#define PTR_SUB(b,o) ( (void*) ((char*)(b) - (o)) )
46
47alloc_pool_t
48pool_create(size_t size, size_t quantum, void (*bomb)(const char*, const char*, int), int flags)
49{
50 struct alloc_pool *pool;
51
52 if ((MINALIGN & (MINALIGN - 1)) != (0)) {
53 if (bomb)
54 (*bomb)("Compiler error: MINALIGN is not a power of 2", __FILE__, __LINE__);
55 return NULL;
56 }
57
58 if (!(pool = new0(struct alloc_pool)))
59 return NULL;
60
61 if (!size)
62 size = POOL_DEF_EXTENT;
63 if (!quantum)
64 quantum = MINALIGN;
65
66 if (flags & POOL_INTERN) {
67 if (size <= sizeof (struct pool_extent))
68 size = quantum;
69 else
70 size -= sizeof (struct pool_extent);
71 flags |= POOL_PREPEND;
72 }
73
74 if (quantum <= 1)
75 flags = (flags | POOL_NO_QALIGN) & ~POOL_QALIGN_P2;
76 else if (!(flags & POOL_NO_QALIGN)) {
77 if (size % quantum)
78 size += quantum - size % quantum;
79 /* If quantum is a power of 2, we'll avoid using modulus. */
80 if (!(quantum & (quantum - 1)))
81 flags |= POOL_QALIGN_P2;
82 }
83
84 pool->size = size;
85 pool->quantum = quantum;
86 pool->bomb = bomb;
87 pool->flags = flags;
88
89 return pool;
90}
91
92void
93pool_destroy(alloc_pool_t p)

Callers 1

flist_newFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected