TrieChar * alpha_map_char_to_trie_str (const AlphaMap *alpha_map, const AlphaChar *str) { TrieChar *trie_str, *p; trie_str = (TrieChar *) malloc (alpha_char_strlen (str) + 1); for (p = trie_str; *str; p++, str++) { *p = alpha_map_char_to_trie (alpha_map, *str); } *p = 0; return trie_str; }
TrieChar * alpha_map_char_to_trie_str (const AlphaMap *alpha_map, const AlphaChar *str) { TrieChar *trie_str, *p; trie_str = (TrieChar *) malloc (alpha_char_strlen (str) + 1); if (UNLIKELY (!trie_str)) return NULL; for (p = trie_str; *str; p++, str++) { TrieIndex tc = alpha_map_char_to_trie (alpha_map, *str); if (TRIE_INDEX_MAX == tc) goto error_str_allocated; *p = (TrieChar) tc; } *p = 0; return trie_str; error_str_allocated: free (trie_str); return NULL; }