/** * Dispose of the dom * @param d the dom in question */ void dom_dispose( dom *d ) { if ( d->ranges != NULL ) range_array_dispose( d->ranges, 1 ); if ( d->root != NULL ) dom_dispose_node( d->root ); if ( d->pm != NULL ) matrix_dispose( d->pm ); if ( d->buf != NULL ) text_buf_dispose( d->buf ); if ( d->q != NULL ) queue_dispose( d->q ); // rules are read-only from formatter free( d ); }
/** * Create a text buf * @param initial_size the buf's initial size * @return an allocate text_buf or NULL */ text_buf *text_buf_create( int initial_size ) { text_buf *tb = calloc( 1, sizeof(text_buf) ); if ( tb != NULL ) { tb->buf = calloc( initial_size,sizeof(UChar) ); if ( tb->buf == NULL ) { text_buf_dispose( tb ); tb = NULL; } else { tb->allocated = initial_size; tb->len = 0; } } else warning("text_buf: failed to allocate text buf\n"); return tb; }