/* This implementation differs from the standard library version of this function in a number of ways: */
int hmatch_r(const char *match, int last_idx, struct env_entry **retval, struct hsearch_data *htab)
/* This implementation differs from the standard library version of this function in a number of ways: */
int hmatch_r(const char *match, int last_idx, struct env_entry **retval, struct hsearch_data *htab)
{
	unsigned int idx;
	size_t key_len = strlen(match);
	for (idx = last_idx + 1; idx < htab->size; ++idx) {
		if (htab->table[idx].used <= 0)
			continue;
		if (!strncmp(match, htab->table[idx].entry.key, key_len)) {
			*retval = &htab->table[idx].entry;
			return idx;
		}
	}
	__set_errno(ESRCH);
	*retval = NULL;
	return 0;
}