struct variable *scope_get(struct block *block, rt_value name) { struct block *defined_block = scope_defined(block, name, true); if(defined_block == block) { return kh_value(block->variables, kh_get(block, block->variables, name)); } else if(defined_block) { struct variable *var; khiter_t k = kh_get(block, defined_block->variables, name); var = kh_value(defined_block->variables, k); var->type = V_HEAP; var->owner->heap_vars = true; /* * Make sure the defined block is required by the current block and parents. */ while(block != defined_block) { block_require_scope(block, defined_block); block = block->parent; } return var; } else return scope_declare_var(block, name); }
/* set the origin ASN for a given prefix as observed by a given peer */ static int set_pfx_peer_origin(struct bgpcorsaro_pfxmonitor_state_t *state, const bgpstream_pfx_storage_t *pfx, uint32_t peer_asn, uint32_t origin_asn) { khiter_t k; int khret; khash_t(peer_asn_map) * pam; /* does the prefix already exist, if not, create it */ if ((k = kh_get(pfx_info_map, state->pfx_info, *pfx)) == kh_end(state->pfx_info)) { /* no, insert it */ k = kh_put(pfx_info_map, state->pfx_info, *pfx, &khret); /* create a peer-asn map */ if ((pam = kh_init(peer_asn_map)) == NULL) { return -1; } kh_value(state->pfx_info, k) = pam; } else { pam = kh_value(state->pfx_info, k); } /* does the peer exist? ({pfx}{peer}), if not, create it */ if ((k = kh_get(peer_asn_map, pam, peer_asn)) == kh_end(pam)) { k = kh_put(peer_asn_map, pam, peer_asn, &khret); } /* set the origin ASN for this pfx/peer combo */ kh_value(pam, k) = origin_asn; return 0; }
h2o_filecache_ref_t *h2o_filecache_open_file(h2o_filecache_t *cache, const char *path, int oflag) { khiter_t iter = kh_get(opencache_set, cache->hash, path); h2o_filecache_ref_t *ref; int dummy; /* lookup cache, and return the one if found */ if (iter != kh_end(cache->hash)) { ref = H2O_STRUCT_FROM_MEMBER(h2o_filecache_ref_t, _path, kh_key(cache->hash, iter)); ++ref->_refcnt; goto Exit; } /* create a new cache entry */ ref = h2o_mem_alloc(offsetof(h2o_filecache_ref_t, _path) + strlen(path) + 1); ref->_refcnt = 1; ref->_lru = (h2o_linklist_t){NULL}; strcpy(ref->_path, path); /* if cache is used, then... */ if (cache->capacity != 0) { /* purge one entry from LRU if cache is full */ if (kh_size(cache->hash) == cache->capacity) { h2o_filecache_ref_t *purge_ref = H2O_STRUCT_FROM_MEMBER(h2o_filecache_ref_t, _lru, cache->lru.prev); khiter_t purge_iter = kh_get(opencache_set, cache->hash, purge_ref->_path); assert(purge_iter != kh_end(cache->hash)); release_from_cache(cache, purge_iter); } /* assign the new entry */ ++ref->_refcnt; kh_put(opencache_set, cache->hash, ref->_path, &dummy); h2o_linklist_insert(cache->lru.next, &ref->_lru); } /* open the file, or memoize the error */ if ((ref->fd = open(path, oflag)) != -1 && fstat(ref->fd, &ref->st) == 0) { ref->_last_modified.str[0] = '\0'; ref->_etag.len = 0; } else { ref->open_err = errno; if (ref->fd != -1) { close(ref->fd); ref->fd = -1; } } Exit: /* if the cache entry retains an error, return it instead of the reference */ if (ref->fd == -1) { errno = ref->open_err; h2o_filecache_close_file(ref); ref = NULL; } return ref; }
int main() { int ret, is_missing; khiter_t k; khash_t(32) *h = kh_init(32); k = kh_put(32, h, 5, &ret); kh_value(h, k) = 10; k = kh_get(32, h, 10); is_missing = (k == kh_end(h)); k = kh_get(32, h, 5); kh_del(32, h, k); for (k = kh_begin(h); k != kh_end(h); ++k) if (kh_exist(h, k)) kh_value(h, k) = 1; kh_destroy(32, h); return 0; }
/** *Set chromosome name */ void bcf_set_chrom(bcf_hdr_t *h, bcf1_t *v, const char* chrom) { vdict_t *d = (vdict_t*)h->dict[BCF_DT_CTG]; khint_t k = kh_get(vdict, d, chrom); if (k == kh_end(d)) { fprintf(stderr, "[E:%s:%d %s] contig '%s' is not defined in the header\n", __FILE__, __LINE__, __FUNCTION__, chrom); kstring_t contig = {0,0,0}; ksprintf(&contig, "##contig=<ID=%s,length=2147483647>", chrom); bcf_hdr_append(h, contig.s); if (contig.m) free(contig.s); k = kh_get(vdict, d, chrom); } v->rid = kh_val(d, k).id; };
MRB_API mrb_value mrb_hash_delete_key(mrb_state *mrb, mrb_value hash, mrb_value key) { khash_t(ht) *h = RHASH_TBL(hash); khiter_t k; mrb_value delVal; mrb_int n; if (h) { k = kh_get(ht, mrb, h, key); if (k != kh_end(h)) { delVal = kh_value(h, k).v; n = kh_value(h, k).n; kh_del(ht, mrb, h, k); for (k = kh_begin(h); k != kh_end(h); k++) { if (!kh_exist(h, k)) continue; if (kh_value(h, k).n > n) kh_value(h, k).n--; } return delVal; } } /* not found */ return mrb_nil_value(); }
/* ------------------------------------------------------ */ mrb_sym mrb_intern(mrb_state *mrb, const char *name) { khash_t(n2s) *h = mrb->name2sym; khash_t(s2n) *rh = mrb->sym2name; khiter_t k; size_t len; char *p; mrb_sym sym; k = kh_get(n2s, h, name); if (k != kh_end(h)) return kh_value(h, k); sym = ++mrb->symidx; len = strlen(name); p = mrb_malloc(mrb, len+1); memcpy(p, name, len); p[len] = 0; k = kh_put(n2s, h, p); kh_value(h, k) = sym; k = kh_put(s2n, rh, sym); kh_value(rh, k) = p; return sym; }
// This is called when the headers are received so we can look for a message waiting for // this person, or leave them connected until one comes, or time them out after 50s maybe? void receivedHeaders(clientStatus *thisClient) { printf ("Connected by >%s<\r\n", thisClient->clientId); // Check to see if there's a message queued for this person // if so, send it and drop the connection khiter_t q = kh_get(queue, queue, (char*)thisClient->clientId); if (q != kh_end(queue)) { char *queuedMessage; kl_shift(messages, kh_value(queue,q), &queuedMessage); // Now send the message to the person and close snprintf(httpResponse, HTTP_RESPONSE_SIZE, HTTP_TEMPLATE, (int)strlen(queuedMessage), queuedMessage); // Compose the response message free(queuedMessage); write(thisClient->io.fd, httpResponse, strlen(httpResponse)); // Send it closeConnectionSkipHash((ev_io*)thisClient); // If that was the last one, free the list and remove it from the hash if (!kh_value(queue, q)->head->next) { kl_destroy(messages, kh_value(queue, q)); // Free the list free((void*)kh_key(queue, q)); // Free the key (the client id) kh_del(queue, queue, q); // Remove this client id from the hash } } else { // If there's no message, then add their client id to the hash for later int ret; khiter_t k = kh_put(clientStatuses, clientStatuses, thisClient->clientId, &ret); kh_value(clientStatuses, k) = thisClient; } }
array_t * hash_get(hash_t *hash, char *key) { khint_t k; k = kh_get(str, hash->table, key); return (k == kh_end(hash->table) ? NULL : kh_val(hash->table, k)); }
char *faidx_fetch_seq(const faidx_t *fai, char *c_name, int p_beg_i, int p_end_i, int *len) { int l; char c; khiter_t iter; faidx1_t val; char *seq=NULL; // Adjust position iter = kh_get(s, fai->hash, c_name); if(iter == kh_end(fai->hash)) return 0; val = kh_value(fai->hash, iter); if(p_end_i < p_beg_i) p_beg_i = p_end_i; if(p_beg_i < 0) p_beg_i = 0; else if(val.len <= p_beg_i) p_beg_i = val.len - 1; if(p_end_i < 0) p_end_i = 0; else if(val.len <= p_end_i) p_end_i = val.len - 1; // Now retrieve the sequence l = 0; seq = (char*)malloc(p_end_i - p_beg_i + 2); razf_seek(fai->rz, val.offset + p_beg_i / val.line_blen * val.line_len + p_beg_i % val.line_blen, SEEK_SET); while (razf_read(fai->rz, &c, 1) == 1 && l < p_end_i - p_beg_i + 1) if (isgraph(c)) seq[l++] = c; seq[l] = '\0'; *len = l; return seq; }
static char *drop_rg(char *hdtxt, rghash_t h, int *len) { char *p = hdtxt, *q, *r, *s; kstring_t str; memset(&str, 0, sizeof(kstring_t)); while (1) { int toprint = 0; q = strchr(p, '\n'); if (q == 0) q = p + strlen(p); if (q - p < 3) break; // the line is too short; then stop if (strncmp(p, "@RG\t", 4) == 0) { int c; khint_t k; if ((r = strstr(p, "\tID:")) != 0) { r += 4; for (s = r; *s != '\0' && *s != '\n' && *s != '\t'; ++s); c = *s; *s = '\0'; k = kh_get(rg, h, r); *s = c; if (k != kh_end(h)) toprint = 1; } } else toprint = 1; if (toprint) { kputsn(p, q - p, &str); kputc('\n', &str); } p = q + 1; } *len = str.l; return str.s; }
bcf_hrec_t *bcf_hdr_get_hrec(bcf_hdr_t *hdr, int type, char *id) { vdict_t *d = type==BCF_HL_CTG ? (vdict_t*)hdr->dict[BCF_DT_CTG] : (vdict_t*)hdr->dict[BCF_DT_ID]; khint_t k = kh_get(vdict, d, id); if ( k == kh_end(d) ) return NULL; return kh_val(d, k).hrec[type==BCF_HL_CTG?0:type]; }
char *faidx_fetch_seq(const faidx_t *fai, const char *c_name, int p_beg_i, int p_end_i, int *len) { int l; char c; khiter_t iter; faidx1_t val; char *seq=NULL; // Adjust position iter = kh_get(s, fai->hash, c_name); if(iter == kh_end(fai->hash)) return 0; val = kh_value(fai->hash, iter); if(p_end_i < p_beg_i) p_beg_i = p_end_i; if(p_beg_i < 0) p_beg_i = 0; else if(val.len <= p_beg_i) p_beg_i = val.len - 1; if(p_end_i < 0) p_end_i = 0; else if(val.len <= p_end_i) p_end_i = val.len - 1; // Now retrieve the sequence int ret = bgzf_useek(fai->bgzf, val.offset + p_beg_i / val.line_blen * val.line_len + p_beg_i % val.line_blen, SEEK_SET); if ( ret<0 ) { *len = -1; fprintf(stderr, "[fai_fetch_seq] Error: fai_fetch failed. (Seeking in a compressed, .gzi unindexed, file?)\n"); return NULL; } l = 0; seq = (char*)malloc(p_end_i - p_beg_i + 2); while ( (c=bgzf_getc(fai->bgzf))>=0 && l < p_end_i - p_beg_i + 1) if (isgraph(c)) seq[l++] = c; seq[l] = '\0'; *len = l; return seq; }
struct variable *scope_define(struct block *block, rt_value name) { if(scope_defined(block, name, false)) return kh_value(block->variables, kh_get(block, block->variables, name)); else return scope_declare_var(block, name); }
/* ------------------------------------------------------ */ mrb_sym mrb_intern2(mrb_state *mrb, const char *name, size_t len) { khash_t(n2s) *h = mrb->name2sym; symbol_name sname; khiter_t k; mrb_sym sym; char *p; sname.len = len; sname.name = name; k = kh_get(n2s, h, sname); if (k != kh_end(h)) return kh_value(h, k); sym = ++mrb->symidx; p = (char *)mrb_malloc(mrb, len+1); memcpy(p, name, len); p[len] = 0; sname.name = (const char*)p; k = kh_put(n2s, h, sname); kh_value(h, k) = sym; return sym; }
int main(int argc, char *argv[]) { int i, l, n = 1000000, ret, c = 0; khash_t(str) *h; khint_t k; h = kh_init(str); if (argc > 1) n = atoi(argv[1]); for (i = 1; i <= n; ++i) { char buf[16]; int2str(i, 16, buf); k = kh_put(str, h, strdup(buf), &ret); kh_val(h, k) = i; } for (i = 1; i <= n; ++i) { char buf[16]; int2str(i, 10, buf); k = kh_get(str, h, buf); if (k != kh_end(h)) ++c; } for (k = kh_begin(h); k != kh_end(h); ++k) // explicitly freeing memory takes 10-20% CPU time. if (kh_exist(h, k)) free((char*)kh_key(h, k)); printf("%d\n", c); kh_destroy(str, h); return 0; }
bool pic_weak_has(pic_state *pic, pic_value weak, pic_value key) { khash_t(weak) *h = &pic_weak_ptr(pic, weak)->hash; return kh_get(weak, h, pic_obj_ptr(key)) != kh_end(h); }
void gl4es_glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params) { khint_t k; int ret; if (glstate->list.pending) flush(); glquery_t *query = NULL; khash_t(queries) *list = glstate->queries; if (! list) { list = glstate->queries = kh_init(queries); // segfaults if we don't do a single put kh_put(queries, list, 1, &ret); kh_del(queries, list, 1); } k = kh_get(queries, list, id); if (k != kh_end(list)) { query = kh_value(list, k); } if(!query) { errorShim(GL_INVALID_OPERATION); return; } noerrorShim(); switch (pname) { case GL_QUERY_RESULT_AVAILABLE: *params = GL_FALSE; break; case GL_QUERY_RESULT: *params = query->num; break; default: errorShim(GL_INVALID_ENUM); break; } }
void gl4es_glBeginQuery(GLenum target, GLuint id) { if(target!=GL_SAMPLES_PASSED) { errorShim(GL_INVALID_ENUM); return; } if (glstate->list.pending) flush(); khint_t k; int ret; glquery_t *query; khash_t(queries) *list = glstate->queries; if (! list) { list = glstate->queries = kh_init(queries); // segfaults if we don't do a single put kh_put(queries, list, 1, &ret); kh_del(queries, list, 1); } k = kh_get(queries, list, id); if (k != kh_end(list)) { query = kh_value(list, k); } else { k = kh_put(queries, list, id, &ret); query = kh_value(list, k) = malloc(sizeof(glquery_t)); } query->target = target; query->num = 0; active_samples_passed = query; noerrorShim(); }
static void sparse_set_f(isize_data_t data, int at, isize_insert_t field, uint64_t value) { isize_sparse_data_t *a = data.sparse; khash_t(m32) *h = a->array; khint_t k = kh_get(m32, h, at); isize_sparse_record_t *rec; if (k != kh_end(h)) { rec = kh_value(h, k); } else if (value != 0) { rec = malloc(sizeof(isize_sparse_record_t)); if (rec != NULL) { rec->isize_inward = 0; rec->isize_outward = 0; rec->isize_other = 0; int stupid = 0; khint_t it = kh_put(m32, h, at, & stupid); kh_value(h, it) = rec; a->max = max(at, a->max); } else { fprintf(pysamerr, "%s\n", "Failed to allocate memory for isize_sparse_record_t"); exit(11); } } else { return; } if (field == IN) { rec->isize_inward = value; } else if (field == OUT) { rec->isize_outward = value; } else { rec->isize_other = value; } }
void h2o_http2_conn_unregister_stream(h2o_http2_conn_t *conn, h2o_http2_stream_t *stream) { khiter_t iter = kh_get(h2o_http2_stream_t, conn->open_streams, stream->stream_id); assert(iter != kh_end(conn->open_streams)); kh_del(h2o_http2_stream_t, conn->open_streams, iter); switch (stream->state) { case H2O_HTTP2_STREAM_STATE_RECV_PSUEDO_HEADERS: case H2O_HTTP2_STREAM_STATE_RECV_HEADERS: case H2O_HTTP2_STREAM_STATE_RECV_BODY: assert(! h2o_http2_conn_stream_is_linked(stream)); break; case H2O_HTTP2_STREAM_STATE_REQ_PENDING: if (h2o_http2_conn_stream_is_linked(stream)) { unlink_stream(&conn->_pending_reqs, stream); } break; case H2O_HTTP2_STREAM_STATE_SEND_HEADERS: case H2O_HTTP2_STREAM_STATE_SEND_BODY: case H2O_HTTP2_STREAM_STATE_END_STREAM: --conn->num_responding_streams; if (h2o_http2_conn_stream_is_linked(stream)) { unlink_stream( h2o_http2_stream_has_pending_data(stream) ? &conn->_write.streams_with_pending_data : &conn->_write.streams_without_pending_data, stream); } break; } if (conn->state != H2O_HTTP2_CONN_STATE_IS_CLOSING) run_pending_requests(conn); }
void h2o_http2_conn_unregister_stream(h2o_http2_conn_t *conn, h2o_http2_stream_t *stream) { khiter_t iter = kh_get(h2o_http2_stream_t, conn->streams, stream->stream_id); assert(iter != kh_end(conn->streams)); kh_del(h2o_http2_stream_t, conn->streams, iter); assert(h2o_http2_scheduler_is_open(&stream->_refs.scheduler)); h2o_http2_scheduler_close(&stream->_refs.scheduler); switch (stream->state) { case H2O_HTTP2_STREAM_STATE_IDLE: case H2O_HTTP2_STREAM_STATE_RECV_HEADERS: case H2O_HTTP2_STREAM_STATE_RECV_BODY: assert(!h2o_linklist_is_linked(&stream->_refs.link)); break; case H2O_HTTP2_STREAM_STATE_REQ_PENDING: assert(h2o_linklist_is_linked(&stream->_refs.link)); h2o_linklist_unlink(&stream->_refs.link); break; case H2O_HTTP2_STREAM_STATE_SEND_HEADERS: case H2O_HTTP2_STREAM_STATE_SEND_BODY: case H2O_HTTP2_STREAM_STATE_END_STREAM: if (h2o_linklist_is_linked(&stream->_refs.link)) h2o_linklist_unlink(&stream->_refs.link); break; } if (stream->state != H2O_HTTP2_STREAM_STATE_END_STREAM) h2o_http2_stream_set_state(conn, stream, H2O_HTTP2_STREAM_STATE_END_STREAM); if (conn->state < H2O_HTTP2_CONN_STATE_IS_CLOSING) { run_pending_requests(conn); update_idle_timeout(conn); } }
// Check contig entries match reference // We check that these match the reference just loaded static void brkpnt_check_refs_match(cJSON *json, const ChromHash *genome, const char *path) { cJSON *version = json_hdr_get(json, "format_version", cJSON_Number, path); if(version->valueint <= 2) return; cJSON *command = json_hdr_get_curr_cmd(json, path); cJSON *brkpnts = json_hdr_get(command, "breakpoints", cJSON_Object, path); cJSON *contigs = json_hdr_get(brkpnts, "contigs", cJSON_Array, path); cJSON *contig; size_t num_chroms = 0; for(contig = contigs->child; contig; contig = contig->next, num_chroms++) { cJSON *id = json_hdr_get(contig, "id", cJSON_String, path); cJSON *len = json_hdr_get(contig, "length", cJSON_Number, path); // Check chrom is loaded in ref and of expected length khiter_t k = kh_get(kChromHash, genome, id->valuestring); if(k == kh_end(genome)) warn("Cannot find chrom [%s]", id->valuestring); else { const read_t *r = kh_value(genome, k); if(r->seq.end != (size_t)len->valueint) { warn("Chrom lengths do not match %s input:%li ref:%zu", id->valuestring, len->valueint, r->seq.end); } } } if(num_chroms != kh_size(genome)) { warn("Number of chromosomes differ: %zu in header vs %zu in ref", num_chroms, (size_t)kh_size(genome)); } }
parg_buffer* parg_asset_to_buffer(parg_token id) { parg_assert(_asset_registry, "Uninitialized asset registry"); khiter_t iter = kh_get(assmap, _asset_registry, id); parg_assert(iter != kh_end(_asset_registry), "Unknown token"); return kh_value(_asset_registry, iter); }
bntseq_t *bns_restore(const char *prefix) { char ann_filename[1024], amb_filename[1024], pac_filename[1024], alt_filename[1024]; FILE *fp; bntseq_t *bns; strcat(strcpy(ann_filename, prefix), ".ann"); strcat(strcpy(amb_filename, prefix), ".amb"); strcat(strcpy(pac_filename, prefix), ".pac"); bns = bns_restore_core(ann_filename, amb_filename, pac_filename); if (bns == 0) return 0; if ((fp = fopen(strcat(strcpy(alt_filename, prefix), ".alt"), "r")) != 0) { // read .alt file if present char str[1024]; khash_t(str) *h; int i, absent; khint_t k; h = kh_init(str); for (i = 0; i < bns->n_seqs; ++i) { k = kh_put(str, h, bns->anns[i].name, &absent); kh_val(h, k) = i; } while (fscanf(fp, "%s", str) == 1) { k = kh_get(str, h, str); if (k != kh_end(h)) bns->anns[kh_val(h, k)].is_alt = 1; } kh_destroy(str, h); fclose(fp); } return bns; }
static PyObject* pyext_epoll_unregister(PyObject *self,PyObject *args){ khiter_t hit; int epfd; int fd; struct pyep_data *pyep; struct ev_header *evhdr; if(!PyArg_ParseTuple(args,"ii",&epfd,&fd)){ PyErr_BadArgument(); return NULL; } if((pyep = pyep_getby_epfd(epfd)) == NULL){ PyErr_SetString(PyExc_KeyError,"epoll file descriptor not found"); return NULL; } if((evhdr = evhdr_getby_fd(pyep->evhdr_ht,fd)) == NULL){ PyErr_SetString(PyExc_KeyError,"file descriptor not found"); return NULL; } if(ev_del(&pyep->evdata,evhdr)){ PyErr_SetString(PyExc_SystemError,"unregister event failed"); return NULL; } hit = kh_get(ptr,pyep->evhdr_ht,fd); kh_del(ptr,pyep->evhdr_ht,hit); free(evhdr); Py_INCREF(Py_None); return Py_None; }
/* Returns the appropriate handler, or NULL if the string isn't an URL. */ static const struct hFILE_scheme_handler *find_scheme_handler(const char *s) { static const struct hFILE_scheme_handler unknown_scheme = { hopen_unknown_scheme, hfile_always_local, "built-in", 0 }; char scheme[12]; int i; for (i = 0; i < sizeof scheme; i++) if (isalnum_c(s[i]) || s[i] == '+' || s[i] == '-' || s[i] == '.') scheme[i] = tolower_c(s[i]); else if (s[i] == ':') break; else return NULL; // 1 byte schemes are likely windows C:/foo pathnames if (i <= 1 || i >= sizeof scheme) return NULL; scheme[i] = '\0'; pthread_mutex_lock(&plugins_lock); if (! schemes) load_hfile_plugins(); pthread_mutex_unlock(&plugins_lock); khint_t k = kh_get(scheme_string, schemes, scheme); return (k != kh_end(schemes))? kh_value(schemes, k) : &unknown_scheme; }
int hash_set_has(hash_set_t *self, int uid) { khiter_t k = kh_get(uid, self, uid); if ( k < kh_end(self)) { return kh_exist(self, k); } return 0; }
GIT__USE_OIDMAP git_commit_list_node *git_revwalk__commit_lookup( git_revwalk *walk, const git_oid *oid) { git_commit_list_node *commit; khiter_t pos; int ret; /* lookup and reserve space if not already present */ pos = kh_get(oid, walk->commits, oid); if (pos != kh_end(walk->commits)) return kh_value(walk->commits, pos); commit = git_commit_list_alloc_node(walk); if (commit == NULL) return NULL; git_oid_cpy(&commit->oid, oid); pos = kh_put(oid, walk->commits, &commit->oid, &ret); assert(ret != 0); kh_value(walk->commits, pos) = commit; return commit; }
/* ------------------------------------------------------ */ static mrb_sym sym_intern(mrb_state *mrb, const char *name, size_t len, int lit) { khash_t(n2s) *h = mrb->name2sym; symbol_name sname; khiter_t k; mrb_sym sym; char *p; if (len > UINT16_MAX) { mrb_raise(mrb, E_ARGUMENT_ERROR, "symbol length too long"); } sname.lit = lit; sname.len = len; sname.name = name; k = kh_get(n2s, mrb, h, sname); if (k != kh_end(h)) return kh_value(h, k); sym = ++mrb->symidx; if (lit) { sname.name = name; } else { p = (char *)mrb_malloc(mrb, len+1); memcpy(p, name, len); p[len] = 0; sname.name = (const char*)p; } k = kh_put(n2s, mrb, h, sname); kh_value(h, k) = sym; return sym; }