void st_free_table(st_table *table) { st_clear(table); free(table->bins); free(table); }
void st_free_table(st_table *table) { st_clear(table); st_free_bins(table->bins, table->num_bins); st_dealloc_table(table); }
static VALUE rhash_clear(VALUE hash, SEL sel) { rhash_modify(hash); st_clear(RHASH(hash)->tbl); return hash; }
//bool parse_token(sfilter * sf, stoken_t *sout) { bool parse_token(const char *cs, const size_t len, size_t * pos, stoken_t * st, char delim) { st_clear(st); if (*pos == 0 && delim != CHAR_NULL) { *pos = parse_string_core(cs, len, 0, st, delim, 0); return true; } while (*pos < len) { const int ch = (int) (cs[*pos]); if (ch < 0 || ch > 127) { *pos += 1; continue; } //printf("CHAR = %c, POS=%d\n", (char)(ch), *pos); pt2Function fnptr = char_parse_map[ch]; *pos = (*fnptr) (cs, len, *pos, st); if (st->type != CHAR_NULL) { //printf("POS = %d, %s \n", *pos, st->val); return true; } } return false; }
size_t parse_slash(const char *cs, const size_t len, size_t pos, stoken_t * st) { size_t pos1 = pos + 1; if (pos1 == len || cs[pos1] != '*') { return parse_operator1(cs, len, pos, st); } size_t inc = is_mysql_comment(cs, len, pos); if (inc == 0) { const char *ptr = strstr(cs + pos, "*/"); if (ptr == NULL) { // unterminated comment st_assign_cstr(st, 'c', cs + pos); return len; } else { st_assign(st, 'c', cs + pos, (ptr + 2) - (cs + pos)); return (ptr - cs) + 2; } } else { // MySQL Comment st_clear(st); return pos + inc; } }
static VALUE stop_stat_server() { if (logger->enabled == Qtrue) stop_stat_tracing(); // Destroy the list which aggregates messages message_list_destroy(); // Clear object_table which holds object allocation info st_foreach(logger->object_table, free_values_i, 0); st_clear(logger->object_table); st_foreach(logger->str_table, free_keys_i, 0); st_clear(logger->str_table); msgpack_sbuffer_free(logger->sbuf); msgpack_packer_free(logger->msgpacker); zmq_close(zmq_publisher); zmq_close(zmq_response_socket); zmq_ctx_destroy(zmq_context); free(logger); logger = 0; return Qnil; }
/* * call-seq: * Byebug.contexts -> array * * Returns an array of all contexts. */ static VALUE Contexts(VALUE self) { volatile VALUE list; volatile VALUE new_list; VALUE context; threads_table_t *t_tbl; debug_context_t *dc; int i; UNUSED(self); check_started(); new_list = rb_ary_new(); list = rb_funcall(rb_cThread, rb_intern("list"), 0); for (i = 0; i < RARRAY_LENINT(list); i++) { VALUE thread = rb_ary_entry(list, i); thread_context_lookup(thread, &context); rb_ary_push(new_list, context); } Data_Get_Struct(threads, threads_table_t, t_tbl); st_clear(t_tbl->tbl); for (i = 0; i < RARRAY_LENINT(new_list); i++) { context = rb_ary_entry(new_list, i); Data_Get_Struct(context, debug_context_t, dc); st_insert(t_tbl->tbl, dc->thread, context); } return new_list; }
size_t parse_operator2(const char *cs, const size_t len, size_t pos, stoken_t * st) { if (pos + 1 >= len) { return parse_operator1(cs, len, pos, st); } char op2[3] = { cs[pos], cs[pos + 1], CHAR_NULL }; // Special Hack for MYSQL style comments // instead of turning: // /*! FOO */ into FOO by rewriting the string, we // turn it into FOO */ and ignore the ending comment // TODO: do we need "&& this->is_started_mysql_comment" // so we don't have FP? if (op2[0] == '*' && op2[1] == '/') { st_clear(st); return pos + 2; } else if (pos + 2 < len && op2[0] == '<' && op2[1] == '=' && cs[pos + 2] == '>') { // special 3-char operator st_assign_cstr(st, 'o', "<=>"); return pos + 3; } else if (is_operator2(op2)) { if (streq(op2, "&&") || streq(op2, "||")) { st_assign_cstr(st, '&', op2); } else { // normal 2 char operator st_assign_cstr(st, 'o', op2); } return pos + 2; } else { // must be a single char operator return parse_operator1(cs, len, pos, st); } }
void st_reset (ddb_dsp_context_t *_src) { ddb_soundtouch_t *st = (ddb_soundtouch_t *)_src; st_clear (st->st); }
bool filter_fold(sfilter * sf, stoken_t * sout) { stoken_t *last = &sf->fold_last; stoken_t *current = &sf->fold_current; //printf("state = %d\n", sf->fold_state); if (sf->fold_state == 4 && !st_is_empty(last)) { //printf("LINE = %d\n", __LINE__); st_copy(sout, last); //printf("%d emit = %c, %s\n", __LINE__, sout->type, sout->val); sf->fold_state = 2; st_clear(last); return true; } while (filter_syntax(sf, current)) { //printf("state = %d\n", sf->fold_state); //printf("current = %c, %s\n", current->type, current->val); if (sf->fold_state == 0) { if (current->type == '(') { continue; } if (st_is_unary_op(current)) { continue; } sf->fold_state = 1; } if (st_is_empty(last)) { //printf("LINE = %d\n", __LINE__); if (current->type == '1') { //printf("LINE = %d\n", __LINE__); sf->fold_state = 2; st_copy(last, current); } //printf("LINE = %d\n", __LINE__); st_copy(sout, current); //printf("emit = %c, %s\n", sout->type, sout->val); return true; } else if (last->type == '1' && st_is_arith_op(current)) { //printf("LINE = %d\n", __LINE__); st_copy(last, current); //sf->fold_state = 1; } else if (last->type == 'o' && current->type == '1') { //printf("LINE = %d\n", __LINE__); //continue; st_copy(last, current); } else { //printf("LINE = %d\n", __LINE__); if (sf->fold_state == 2) { if (last->type != '1') { st_copy(sout, last); st_copy(last, current); // printf("%d emit = %c, %s\n", __LINE__, sout->type, sout->val); sf->fold_state = 4; } else { st_copy(sout, current); st_clear(last); } return true; } else { //printf("LINE = %d\n", __LINE__); if (last->type == 'o') { //printf("STATE = %d, LINE = %d\n", sf->fold_state, __LINE__); st_copy(sout, last); st_copy(last, current); sf->fold_state = 4; } else { //printf("LINE = %d\n", __LINE__); sf->fold_state = 2; st_copy(sout, current); st_clear(last); } //printf("emit = %c, %s\n", sout->type, sout->val); return true; } } } if (!st_is_empty(last)) { if (st_is_arith_op(last)) { //printf("\nstate = %d, emit = %c, %s\n", sf->fold_state, last->type, last->val); st_copy(sout, last); st_clear(last); return true; } else { st_clear(last); } } return false; }
bool filter_syntax(sfilter * sf, stoken_t * sout) { stoken_t *last = &sf->syntax_last; stoken_t *current = &sf->syntax_current; while (parse_token(sf->s, sf->slen, &sf->pos, current, sf->delim)) { char ttype = current->type; if (ttype == 'c') { st_copy(&sf->syntax_comment, current); continue; } st_clear(&sf->syntax_comment); if (last->type == CHAR_NULL) { switch (ttype) { // items that have special needs case 's': st_copy(last, current); continue; case 'n': case 'k': case 'U': case '&': case 'o': if (st_is_multiword_start(current)) { st_copy(last, current); continue; } else if (current->type == 'o' || current->type == '&') { //} else if (st_is_unary_op(current)) { st_copy(last, current); continue; } else { // copy to out st_copy(sout, current); return true; } default: // copy to out st_copy(sout, current); return true; } } switch (ttype) { case 's': if (last->type == 's') { //this->last_token.second += this->current.second; continue; } else { st_copy(sout, last); st_copy(last, current); return true; } break; case 'o': // case 'U': // case '&': if (st_is_unary_op(current)) { if (last->type == 'o' || last->type == '&' || last->type == 'U') { //if (st_is_unary_op(last)) { continue; } else { st_copy(sout, last); st_copy(last, current); return true; } } else if (syntax_merge_words(last, current)) { continue; } else { // no match st_copy(sout, last); st_copy(last, current); return true; } break; case 'n': case 'k': if (syntax_merge_words(last, current)) { continue; } else { // total no match st_copy(sout, last); st_copy(last, current); return true; } break; default: // fix up for ambigous "IN" // handle case where IN is typically a function // but used in compound "IN BOOLEAN MODE" jive if (last->type == 'n' && !strcmp(last->val, "IN")) { st_copy(last, current); st_assign_cstr(sout, 'f', "IN"); return true; } else { // no match at all st_copy(sout, last); st_copy(last, current); return true; } break; } } // final cleanup if (last->type) { st_copy(sout, last); st_clear(last); return true; } else if (sf->syntax_comment.type) { st_copy(sout, &sf->syntax_comment); st_clear(&sf->syntax_comment); return true; } else { return false; } }