1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#include <stdio.h> #include <stdlib.h> #include "env.h" static const char *env_cache[PCIDEV_MAX_ENV] = {0}; const char *pcidev_getenv(pcidev_env_t env, const char *var) { if (!env_cache[env]) { const char *var_env = getenv(var); env_cache[env] = var_env?var_env:(void*)-1; return var_env; } return (env_cache[env] == (void*)-1)?NULL:env_cache[env]; }