int env_get(strm_env* env, strm_string name, strm_value* val) { khiter_t k; if (!strm_str_intern_p(name)) { name = strm_str_intern_str(name); } k = kh_get(env, env, name); if (k == kh_end(env)) return STRM_NG; *val = kh_value(env, k); return STRM_OK; }
strm_string strm_str_intern_str(strm_string str) { if (strm_str_intern_p(str)) { return str; } if (!strm_event_loop_started) { return str_intern(strm_str_ptr(str), strm_str_len(str), 0); } pthread_mutex_lock(&sym_mutex); str = str_intern(strm_str_ptr(str), strm_str_len(str), 0); pthread_mutex_unlock(&sym_mutex); return str; }
static int env_set(strm_env *env, strm_string name, strm_value val) { int r; khiter_t k; assert(env != globals || !strm_event_loop_started); if (!strm_str_intern_p(name)) { name = strm_str_intern_str(name); } k = kh_put(env, env, name, &r); if (r <= 0) return STRM_NG; /* r=0 key is present in the hash table */ /* r=-1 operation failed */ kh_value(env, k) = val; return STRM_OK; }