NAME

trim_word_list_empty_entries_at_tail - Removes empty entries from the tail end (only) of a word list.

SYNOPSIS

#include "l/l_word_list.h"

Example compile flags (system dependent):
  -DLINUX_X86_64 -DLINUX_X86_64_OPTERON  -DGNU_COMPILER 
   -I/home/kobus/include
   -L/home/kobus/misc/load/linux_x86_64_opteron -L/usr/lib/x86_64-linux-gnu
  -lKJB                               -lfftw3  -lgsl -lgslcblas -ljpeg  -lSVM -lstdc++                    -lpthread -lSLATEC -lg2c    -lacml -lacml_mv -lblas -lg2c      -lncursesw 


int trim_word_list_empty_entries_at_tail(Word_list *word_list_ptr);

DESCRIPTION

If you have called function append_word_list on Word_list L, then you may have increased the number of list entries in L to more than the number of strings stored in the list. If you then use list concatenation on L and M, the empty entries at the end of L will be copied before the M is copied, i.e., the resulting list will have a hole in the middle. That could be undesirable. This function will remedy that problem by removing all empty entries from the end of the list. For example:
 Word_list* lp = 0;
 ERE(get_target_word_list(&lp, 0));             # zero empty entries
 ERE(append_word_list(&lp, "alpha"));           # unknown num empty entries
 # If you concatenate lp and another list now, it could have a hole in it.
 ERE(trim_word_list_empty_entries_at_tail(lp)); # zero empty entries
 # Now it is safe to concatenate using lp.
This function does not deallocate anything; the object must still be freed, as usual, after this function, even if num_words goes to zero.

RETURNS

NO_ERROR on success, and ERROR on failure, with an appropriate error message being set.

DISCLAIMER

This software is not adequatedly tested. It is recomended that results are checked independantly where appropriate.

AUTHOR

Kobus Barnard

DOCUMENTER

Kobus Barnard

SEE ALSO

get_target_word_list , ra_get_target_word_list , free_word_list , append_word_list , select_from_word_list , copy_word_list , sort_word_list , search_word_list , search_sorted_word_list , concat_word_lists , read_word_list , fp_read_word_list , sget_word_list , write_word_list , fp_write_word_list , count_strings_in_word_list