Document/RB_Document_Collect_Headers [ Functions ]
FUNCTION
Create a table of pointers to all headers. This is done to have easy access to all heades without having to scan all RB_Parts.
INPUTS
- document -- the document for which the table is created.
OUTPUT
- document->headers
- document->no_headers
SOURCE
void RB_Document_Collect_Headers( struct RB_Document *document ) { struct RB_Part *i_part; struct RB_header **headers; /* Pointer to an array of pointers RB_headers. */ unsigned long count = 0; unsigned long part_count = 0; unsigned long i = 0; RB_Say( "Collecting all headers in a single table\n", SAY_INFO ); for ( i_part = document->parts; i_part; i_part = i_part->next ) { struct RB_header *i_header; /* Count the number of headers */ for ( part_count = 0, i_header = i_part->headers; i_header; i_header = i_header->next ) { part_count++; } /* Compute the total count */ count += part_count; } headers = ( struct RB_header ** ) calloc( count, sizeof( struct RB_header * ) ); for ( i_part = document->parts; i_part; i_part = i_part->next ) { struct RB_header *i_header; for ( i_header = i_part->headers; i_header; i_header = i_header->next ) { headers[i] = i_header; i++; } } document->headers = headers; document->no_headers = count; }