~ubuntu-branches/ubuntu/trusty/serf/trusty-proposed

« back to all changes in this revision

Viewing changes to buckets/allocator.c

  • Committer: Bazaar Package Importer
  • Author(s): Peter Samuelson
  • Date: 2011-06-03 03:18:07 UTC
  • mto: (9.1.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 10.
  • Revision ID: james.westby@ubuntu.com-20110603031807-6y8ky58ac0q82etq
Tags: upstream-0.7.2
ImportĀ upstreamĀ versionĀ 0.7.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
110
110
    return APR_SUCCESS;
111
111
}
112
112
 
113
 
SERF_DECLARE(serf_bucket_alloc_t *) serf_bucket_allocator_create(
 
113
serf_bucket_alloc_t *serf_bucket_allocator_create(
114
114
    apr_pool_t *pool,
115
115
    serf_unfreed_func_t unfreed,
116
116
    void *unfreed_baton)
149
149
    return allocator;
150
150
}
151
151
 
152
 
SERF_DECLARE(apr_pool_t *) serf_bucket_allocator_get_pool(
 
152
apr_pool_t *serf_bucket_allocator_get_pool(
153
153
    const serf_bucket_alloc_t *allocator)
154
154
{
155
155
    return allocator->pool;
156
156
}
157
157
 
158
 
SERF_DECLARE(void *) serf_bucket_mem_alloc(
 
158
 
 
159
void *serf_bucket_mem_alloc(
159
160
    serf_bucket_alloc_t *allocator,
160
161
    apr_size_t size)
161
162
{
187
188
                /* ran out of room. grab another block. */
188
189
                active = apr_allocator_alloc(allocator->allocator, ALLOC_AMT);
189
190
 
 
191
                /* System couldn't provide us with memory. */
 
192
                if (active == NULL)
 
193
                    return NULL;
 
194
 
190
195
                /* link the block into our tracking list */
191
196
                allocator->blocks = active;
192
197
                active->next = head;
201
206
        apr_memnode_t *memnode = apr_allocator_alloc(allocator->allocator,
202
207
                                                     size);
203
208
 
 
209
        if (memnode == NULL)
 
210
            return NULL;
 
211
 
204
212
        node = (node_header_t *)memnode->first_avail;
205
213
        node->u.memnode = memnode;
206
214
        node->size = size;
209
217
    return ((char *)node) + SIZEOF_NODE_HEADER_T;
210
218
}
211
219
 
212
 
SERF_DECLARE(void *) serf_bucket_mem_calloc(
 
220
 
 
221
void *serf_bucket_mem_calloc(
213
222
    serf_bucket_alloc_t *allocator,
214
223
    apr_size_t size)
215
224
{
216
225
    void *mem;
217
226
    mem = serf_bucket_mem_alloc(allocator, size);
 
227
    if (mem == NULL)
 
228
        return NULL;
218
229
    memset(mem, 0, size);
219
230
    return mem;
220
231
}
221
232
 
222
 
SERF_DECLARE(void) serf_bucket_mem_free(
 
233
 
 
234
void serf_bucket_mem_free(
223
235
    serf_bucket_alloc_t *allocator,
224
236
    void *block)
225
237
{
307
319
#endif /* SERF_DEBUG_BUCKET_USE */
308
320
 
309
321
 
310
 
SERF_DECLARE(apr_status_t) serf_debug__record_read(
 
322
apr_status_t serf_debug__record_read(
311
323
    const serf_bucket_t *bucket,
312
324
    apr_status_t status)
313
325
{
331
343
#endif
332
344
}
333
345
 
334
 
SERF_DECLARE(void) serf_debug__entered_loop(serf_bucket_alloc_t *allocator)
 
346
 
 
347
void serf_debug__entered_loop(serf_bucket_alloc_t *allocator)
335
348
{
336
349
#ifdef SERF_DEBUG_BUCKET_USE
337
350
 
353
366
#endif
354
367
}
355
368
 
356
 
SERF_DECLARE(void) serf_debug__closed_conn(serf_bucket_alloc_t *allocator)
 
369
 
 
370
void serf_debug__closed_conn(serf_bucket_alloc_t *allocator)
357
371
{
358
372
#ifdef SERF_DEBUG_BUCKET_USE
359
373
 
364
378
#endif
365
379
}
366
380
 
367
 
SERF_DECLARE(void) serf_debug__bucket_destroy(const serf_bucket_t *bucket)
 
381
 
 
382
void serf_debug__bucket_destroy(const serf_bucket_t *bucket)
368
383
{
369
384
#ifdef SERF_DEBUG_BUCKET_USE
370
385
 
399
414
#endif
400
415
}
401
416
 
402
 
SERF_DECLARE(void) serf_debug__bucket_alloc_check(
 
417
 
 
418
void serf_debug__bucket_alloc_check(
403
419
    serf_bucket_alloc_t *allocator)
404
420
{
405
421
#ifdef SERF_DEBUG_BUCKET_USE