Example #1
0
/*
 * If the given string has not changed, we do not need to update the index.
 * If we need to update the index, allocate enough memory for it.
 */
static bool
same_cache2(CACHE * cache, const char *string, unsigned i_len)
{
    unsigned need;
    size_t s_len = strlen(string);
    bool result = TRUE;

    if (cache->s_len == 0
	|| cache->s_len < s_len
	|| cache->list == 0
	|| !SAME_CACHE(cache, string, (size_t) s_len)) {

	need = (i_len + 1);
	if (cache->list == 0) {
	    cache->list = dlg_malloc(int, need);
	} else if (cache->i_len < i_len) {
Example #2
0
/*
 * If the given string has not changed, we do not need to update the index.
 * If we need to update the index, allocate enough memory for it.
 */
static bool
same_cache2(CACHE * cache, const char *string, unsigned i_len)
{
    unsigned need;
    size_t s_len = strlen(string);

    if (cache->s_len != 0
	&& cache->s_len >= s_len
	&& cache->list != 0
	&& SAME_CACHE(cache, string, (size_t) s_len)) {
	return TRUE;
    }

    need = (i_len + 1);
    if (cache->list == 0) {
	cache->list = dlg_malloc(int, need);
    } else if (cache->i_len < i_len) {