MCPcopy Create free account
hub / github.com/HandBrake/HandBrake / hb_buffer_pool_init

Function hb_buffer_pool_init

libhb/fifo.c:101–135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99#endif
100
101void hb_buffer_pool_init( void )
102{
103 buffers.lock = hb_lock_init();
104 buffers.allocated = 0;
105
106#if defined(HB_BUFFER_DEBUG)
107 buffers.alloc_list = hb_list_init();
108#endif
109
110#if !defined(HB_NO_BUFFER_POOL)
111 /* we allocate pools for sizes 2^10 through 2^25. requests larger than
112 * 2^25 will get passed through to malloc. */
113 int i;
114
115 // Create a queue with empty buffers for non native storage types
116 buffers.pool[0] = hb_fifo_init(BUFFER_POOL_MAX_ELEMENTS*10, 1);
117 buffers.pool[0]->buffer_size = 0;
118
119 // Create larger queue for 2^10 bucket since all allocations smaller than
120 // 2^10 come from here.
121 buffers.pool[BUFFER_POOL_FIRST] = hb_fifo_init(BUFFER_POOL_MAX_ELEMENTS*10, 1);
122 buffers.pool[BUFFER_POOL_FIRST]->buffer_size = 1 << 10;
123
124 /* requests smaller than 2^10 are satisfied from the 2^10 pool. */
125 for ( i = 1; i < BUFFER_POOL_FIRST; ++i )
126 {
127 buffers.pool[i] = buffers.pool[BUFFER_POOL_FIRST];
128 }
129 for ( i = BUFFER_POOL_FIRST + 1; i <= BUFFER_POOL_LAST; ++i )
130 {
131 buffers.pool[i] = hb_fifo_init(BUFFER_POOL_MAX_ELEMENTS, 1);
132 buffers.pool[i]->buffer_size = 1 << i;
133 }
134#endif
135}
136
137#if defined(HB_FIFO_DEBUG)
138

Callers 1

hb_global_initFunction · 0.85

Calls 3

hb_lock_initFunction · 0.85
hb_list_initFunction · 0.85
hb_fifo_initFunction · 0.85

Tested by

no test coverage detected