Lines Matching refs:hdr

85 static void debug_header( memory_header *hdr )  in debug_header()  argument
93 (size_t) hdr, (size_t) hdr->prev, (size_t) hdr->next, in debug_header()
94 hdr->alloc, hdr->size ); in debug_header()
96 (size_t) hdr->prev_free, (size_t) hdr->next_free ); in debug_header()
100 for( i = 0; i < hdr->trace_count; i++ ) in debug_header()
101 mbedtls_fprintf( stderr, "%s\n", hdr->trace[i] ); in debug_header()
128 static int verify_header( memory_header *hdr ) in verify_header() argument
130 if( hdr->magic1 != MAGIC1 ) in verify_header()
138 if( hdr->magic2 != MAGIC2 ) in verify_header()
146 if( hdr->alloc > 1 ) in verify_header()
154 if( hdr->prev != NULL && hdr->prev == hdr->next ) in verify_header()
162 if( hdr->prev_free != NULL && hdr->prev_free == hdr->next_free ) in verify_header()
377 memory_header *hdr, *old = NULL; in buffer_alloc_free() local
393 hdr = (memory_header *) p; in buffer_alloc_free()
395 if( verify_header( hdr ) != 0 ) in buffer_alloc_free()
398 if( hdr->alloc != 1 ) in buffer_alloc_free()
407 hdr->alloc = 0; in buffer_alloc_free()
411 heap.total_used -= hdr->size; in buffer_alloc_free()
415 free( hdr->trace ); in buffer_alloc_free()
416 hdr->trace = NULL; in buffer_alloc_free()
417 hdr->trace_count = 0; in buffer_alloc_free()
422 if( hdr->prev != NULL && hdr->prev->alloc == 0 ) in buffer_alloc_free()
427 hdr->prev->size += sizeof(memory_header) + hdr->size; in buffer_alloc_free()
428 hdr->prev->next = hdr->next; in buffer_alloc_free()
429 old = hdr; in buffer_alloc_free()
430 hdr = hdr->prev; in buffer_alloc_free()
432 if( hdr->next != NULL ) in buffer_alloc_free()
433 hdr->next->prev = hdr; in buffer_alloc_free()
440 if( hdr->next != NULL && hdr->next->alloc == 0 ) in buffer_alloc_free()
445 hdr->size += sizeof(memory_header) + hdr->next->size; in buffer_alloc_free()
446 old = hdr->next; in buffer_alloc_free()
447 hdr->next = hdr->next->next; in buffer_alloc_free()
449 if( hdr->prev_free != NULL || hdr->next_free != NULL ) in buffer_alloc_free()
451 if( hdr->prev_free != NULL ) in buffer_alloc_free()
452 hdr->prev_free->next_free = hdr->next_free; in buffer_alloc_free()
454 heap.first_free = hdr->next_free; in buffer_alloc_free()
456 if( hdr->next_free != NULL ) in buffer_alloc_free()
457 hdr->next_free->prev_free = hdr->prev_free; in buffer_alloc_free()
460 hdr->prev_free = old->prev_free; in buffer_alloc_free()
461 hdr->next_free = old->next_free; in buffer_alloc_free()
463 if( hdr->prev_free != NULL ) in buffer_alloc_free()
464 hdr->prev_free->next_free = hdr; in buffer_alloc_free()
466 heap.first_free = hdr; in buffer_alloc_free()
468 if( hdr->next_free != NULL ) in buffer_alloc_free()
469 hdr->next_free->prev_free = hdr; in buffer_alloc_free()
471 if( hdr->next != NULL ) in buffer_alloc_free()
472 hdr->next->prev = hdr; in buffer_alloc_free()
482 hdr->next_free = heap.first_free; in buffer_alloc_free()
484 heap.first_free->prev_free = hdr; in buffer_alloc_free()
485 heap.first_free = hdr; in buffer_alloc_free()