This used a variable size array on the stack before which is not needed.
This version should be slightly faster and the compiler should be able
to inline it.
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
return -1;
}
- char buffer[strlen(key) + 2];
- pakfire_string_format(buffer, "%s=", key);
+ const size_t length = strlen(key);
for (unsigned int i = 0; jail->env[i]; i++) {
- if (pakfire_string_startswith(jail->env[i], buffer))
+ if ((pakfire_string_startswith(jail->env[i], key)
+ && *(jail->env[i] + length) == '=')) {
return i;
+ }
}
// Nothing found