void cleanup() /* {{{ */ { /* function to run on termination */ keybind *lastbind; /* free memory allocated normally */ check_free(searchstring); free_tasks(head); check_free(cfg.sortmode); free(cfg.version); free(cfg.formats.task); free(cfg.formats.title); free(cfg.formats.view); free(active_filter); while (keybinds!=NULL) { lastbind = keybinds; keybinds = keybinds->next; check_free(lastbind->argstr); free(lastbind); } free_colors(); free_prompts(); free_formats(); /* close open files */ fflush(logfp); fclose(logfp); } /* }}} */
/* Reset a session-record for reuse. */ void reset_session(t_session *session) { long size; check_clear_free(session->file_on_disk, CHECK_USE_STRLEN); #ifdef CIFS check_free(session->extension); #endif check_clear_free(session->local_user, CHECK_USE_STRLEN); check_clear_free(session->remote_user, CHECK_USE_STRLEN); check_free(session->path_info); check_free(session->request_uri); check_free(session->location); if (session->uploaded_file != NULL) { unlink(session->uploaded_file); free(session->uploaded_file); } session->http_headers = remove_http_headers(session->http_headers); if (session->directory != NULL) { pthread_mutex_lock(&(session->directory->client_mutex)); if (session->part_of_dirspeed) { if (--session->directory->nr_of_clients == 0) { session->directory->session_speed = session->directory->upload_speed; } else { session->directory->session_speed = session->directory->upload_speed / session->directory->nr_of_clients; } } pthread_mutex_unlock(&(session->directory->client_mutex)); } #ifdef ENABLE_TOOLKIT if (session->host->toolkit_rules_user != NULL) { free(session->host->toolkit_rules_user); } remove_charlist(&(session->host->toolkit_rules_user_str)); #endif /* HTTP pipelining */ size = session->header_length + session->content_length; if ((session->bytes_in_buffer > size) && session->keep_alive) { session->bytes_in_buffer -= size; memmove(session->request, session->request + size, session->bytes_in_buffer); *(session->request + session->bytes_in_buffer) = '\0'; } else { check_clear_free(session->request, session->buffer_size); session->request = NULL; session->buffer_size = 0; session->bytes_in_buffer = 0; } remove_tempdata(session->tempdata); if (session->host_copied) { free(session->host); } clear_session(session); }
void run_command_color(char *args) /* {{{ */ { /** * create/modify a color rule * syntax: object foreground background [rule] */ char *object = NULL, *fg = NULL, *bg = NULL, *rule = NULL; color_object obj; int ret = 0, fgc, bgc; if (args != NULL) ret = sscanf(args, "%ms %m[a-z0-9-] %m[a-z0-9-] %m[^\n]", &object, &fg, &bg, &rule); if (ret < 3) { statusbar_message(cfg.statusbar_timeout, "syntax: color <object> <foreground> <background> <rule>"); tnc_fprintf(logfp, LOG_ERROR, "syntax: color <object> <foreground> <background> <rule> [%d](%s)", ret, args); goto cleanup; } /* parse object */ obj = parse_object(object); if (obj == OBJECT_NONE) { statusbar_message(cfg.statusbar_timeout, "color: invalid object \"%s\"", object); tnc_fprintf(logfp, LOG_ERROR, "color: invalid object \"%s\"", object); goto cleanup; } /* parse colors */ fgc = parse_color(fg); bgc = parse_color(bg); if (bgc < -2 || fgc < -2) { statusbar_message(cfg.statusbar_timeout, "color: invalid colors \"%s\" \"%s\"", fg, bg); tnc_fprintf(logfp, LOG_ERROR, "color: invalid colors %d:\"%s\" %d:\"%s\"", fgc, fg, bgc, bg); goto cleanup; } /* create color rule */ if (add_color_rule(obj, rule, fgc, bgc)>=0) statusbar_message(cfg.statusbar_timeout, "applied color rule"); else statusbar_message(cfg.statusbar_timeout, "applying color rule failed"); goto cleanup; cleanup: check_free(object); check_free(fg); check_free(bg); check_free(rule); } /* }}} */
/* Get the extension of the file to be processed */ int get_target_extension(t_session *session) { char *last_slash; #ifdef CIFS check_free(session->extension); session->extension = NULL; #endif if ((last_slash = strrchr(session->file_on_disk, '/')) == NULL) { return -1; } if ((session->extension = strrchr(last_slash, '.')) != NULL) { session->extension++; } else { session->extension = session->host->no_extension_as; } #ifdef CIFS if (session->extension != NULL) { if ((session->extension = strdup(session->extension)) == NULL) { return -1; } strlower(session->extension); } #endif return 0; }
void free_colors() /* {{{ */ { /* clean up memory allocated for colors */ color_rule *this, *last; check_free(pairs_used); this = color_rules; while (this != NULL) { last = this; this = this->next; check_free(last->rule); free(last); } } /* }}} */
/* * xfree() - same as free(3). Will not call free(3) if s == NULL. */ void xfree(void *s) { PROF_start(xfree); #if XMALLOC_TRACE xmalloc_show_trace(s, -1); #endif #if XMALLOC_DEBUG if (s != NULL) check_free(s); #endif if (s != NULL) free(s); #if MEM_GEN_TRACE if (tracefp && s) fprintf(tracefp, "f:%p\n", s); #endif PROF_stop(xfree); }
/* Free the thread specific data, this is done if a thread terminates. */ static void free_key_mem (void *mem) { check_free ((struct dl_action_result *) mem); free (mem); __libc_setspecific (key, NULL); }
/* each {...} */ static VALUE each(VALUE obj) { VALUE row; check_free(obj); while ((row = fetch_row(obj)) != Qnil) rb_yield(row); return obj; }
/* * xrealloc() - same as realloc(3). Used for portability. * Never returns NULL; fatal on error. */ void * xrealloc(void *s, size_t sz) { void *p; PROF_start(xrealloc); #if XMALLOC_TRACE xmalloc_show_trace(s, -1); #endif if (sz < 1) sz = 1; #if XMALLOC_DEBUG if (s != NULL) check_free(s); #endif if ((p = realloc(s, sz)) == NULL) { if (failure_notify) { snprintf(msg, 128, "xrealloc: Unable to reallocate %d bytes!\n", (int) sz); (*failure_notify) (msg); } else { perror("realloc"); } exit(1); } #if XMALLOC_DEBUG check_malloc(p, sz); #endif #if XMALLOC_STATISTICS malloc_stat(sz); #endif #if XMALLOC_TRACE xmalloc_show_trace(p, 1); #endif #if MEM_GEN_TRACE if (tracefp) /* new ptr, old ptr, new size */ fprintf(tracefp, "r:%p:%p:%d\n", p, s, sz); #endif PROF_stop(xrealloc); return (p); }
/* free() */ static VALUE res_free(VALUE obj) { struct mysql_res* resp = DATA_PTR(obj); check_free(obj); mysql_free_result(resp->res); resp->freed = Qtrue; store_result_count--; return Qnil; }
/* fetch_hash(with_table=false) */ static VALUE fetch_hash(int argc, VALUE* argv, VALUE obj) { VALUE with_table; check_free(obj); rb_scan_args(argc, argv, "01", &with_table); if (with_table == Qnil) with_table = Qfalse; return fetch_hash2(obj, with_table); }
int main(int argc, char **argv) { check_free(); check_free2(); check_alignment(); check_allocation_near_chunk_size(); check_leak_detection(); check_object_growth(); return 0; }
/* Free the dlerror-related resources. */ void __dlerror_main_freeres (void) { void *mem; /* Free the global memory if used. */ check_free (&last_result); /* Free the TSD memory if used. */ mem = __libc_getspecific (key); if (mem != NULL) free_key_mem (mem); }
void key_tasklist_sort(const char* arg) { /* {{{ */ /* handle a keyboard direction to sort * arg - the mode to sort by (pass NULL to prompt user) * see the manual page for how sort strings are parsed */ char* uuid = NULL; /* store selected task */ struct task* cur = get_task_by_position(selline); if (cur != NULL) { uuid = strdup(cur->uuid); } tnc_fprintf(logfp, LOG_DEBUG_VERBOSE, "sort: initial task uuid=%s", uuid); check_free(cfg.sortmode); if (arg == NULL) { /* store sort string */ cfg.sortmode = calloc(cols, sizeof(char)); statusbar_getstr(&(cfg.sortmode), "sort by: "); sb_timeout = time(NULL) + 3; } else { cfg.sortmode = strdup(arg); } /* run sort */ sort_wrapper(head); /* follow original task */ if (cfg.follow_task) { set_position_by_uuid(uuid); tasklist_check_curs_pos(); } check_free(uuid); /* force redraw */ redraw = true; } /* }}} */
I_ID *create_new_id( D_MOBILE *dMob, int type ) { I_ID *id; ID_HANDLER *handler = get_id_handler( type ); if( ( id = check_free( handler ) ) == NULL ) id = create_raw_id( use_top_id( handler ) ); id->created_by = strdup( dMob ? dMob->name : "system" ); id->modified_by = strdup( dMob ? dMob->name : "system" ); return id; }
/* each_hash(with_table=false) {...} */ static VALUE each_hash(int argc, VALUE* argv, VALUE obj) { VALUE with_table; VALUE hash; check_free(obj); rb_scan_args(argc, argv, "01", &with_table); if (with_table == Qnil) with_table = Qfalse; while ((hash = fetch_hash2(obj, with_table)) != Qnil) rb_yield(hash); return obj; }
void uninstall_crdsys_lists( void ) { crdsys_source_def *csd; update_id++; while( sources ) { csd = sources; sources = sources->next; if( csd->delsource ) (*csd->delsource)( csd->data ); check_free( csd ); } }
void sort_faces(int pm[] , int fpoint[][2] , int ttype[] , int nfaces ) { int *pm_tmp = check_malloc(nfaces * sizeof(int)); int *tp = check_malloc(nfaces * sizeof(int)); int *tp_tmp = check_malloc(nfaces * sizeof(int)); int (*fp)[2] = check_malloc(2 * nfaces * sizeof(int)); int (*fp_tmp)[2] = check_malloc(2 * nfaces * sizeof(int)); int face; for(face = 0; face < nfaces; face++) { tp[face] = ttype[face]; fp[face][0] = fpoint[face][0]; fp[face][1] = fpoint[face][1]; } global_msort(pm , pm_tmp , nfaces , fp , fp_tmp , tp , tp_tmp ); check_free(pm_tmp); check_free(tp); check_free(tp_tmp); check_free(fp); check_free(fp_tmp); }
/* Free all remaining buffers */ void destroy_session(t_session *session) { #ifdef ENABLE_RPROXY if (session->rproxy_kept_alive) { #ifdef ENABLE_TLS if (session->rproxy_use_tls) { tls_close(&(session->rproxy_ssl)); } #endif close(session->rproxy_socket); session->rproxy_kept_alive = false; } #endif check_free(session->request); session->request = NULL; }
/* xxfree() - like xfree(), but we already know s != NULL */ void xxfree(const void *s_const) { void *s = (void *) s_const; #if XMALLOC_TRACE xmalloc_show_trace(s, -1); #endif #if XMALLOC_DEBUG check_free(s); #endif free(s); #if MEM_GEN_TRACE if (tracefp && s) fprintf(tracefp, "f:%p\n", s); #endif }
void *malloc(size_t taille) { t_block *elem; if (taille < 1) return (NULL); elem = check_free(taille); if (elem == NULL) { elem = sbrk(taille + BLOCK_SIZE); if (elem == (void *)-1) return (NULL); putlist(elem, taille); } return (elem + 1); }
/* fetch_fields() */ static VALUE fetch_fields(VALUE obj) { MYSQL_RES* res; MYSQL_FIELD* f; unsigned int n; VALUE ret; unsigned int i; check_free(obj); res = GetMysqlRes(obj); f = mysql_fetch_fields(res); n = mysql_num_fields(res); ret = rb_ary_new2(n); for (i=0; i<n; i++) rb_ary_store(ret, i, make_field_obj(&f[i])); return ret; }
static int Check(const uint8_t *md5Seed) /* 客户端校验 */ { char final_str[129]; int value; printf("** Client version: \t%d.%d\n", fillBuf[0x3B], fillBuf[0x3C]); printf("** MD5 seed: \t%s\n", formatHex(md5Seed, 16)); value = check_init(dataFile); if (value == -1) { printf("!! 8021x.exe info is insufficient, cannot continue client authentication\n"); return 1; } V2_check(md5Seed, final_str); printf("** V2 checksum: \t%s\n", final_str); setProperty(0x17, (uint8_t *)final_str, 32); check_free(); return 0; }
/* Free the dlerror-related resources. */ void __dlerror_main_freeres (void) { /* Free the global memory if used. */ check_free (&last_result); if (__libc_once_get (once) && static_buf == NULL) { /* init () has been run and we don't use the static buffer. So we have a valid key. */ void *mem; /* Free the TSD memory if used. */ mem = __libc_getspecific (key); if (mem != NULL) free_key_mem (mem); } }
static int Check(const u_char *md5Seed) /* 客户端校验 */ { char final_str[129]; int value; printf("** 客户端版本:\t%d.%d\n", fillBuf[0x3B], fillBuf[0x3C]); printf("** MD5种子:\t%s\n", formatHex(md5Seed, 16)); value = check_init(dataFile); if (value == -1) { printf("!! 缺少8021x.exe信息,客户端校验无法继续!\n"); return 1; } V2_check(md5Seed, final_str); printf("** V2校验值:\t%s\n", final_str); setProperty(0x17, (u_char *)final_str, 32); check_free(); return 0; }
/* fetch_field_direct(nr) */ static VALUE fetch_field_direct(VALUE obj, VALUE nr) { MYSQL_RES* res; unsigned int max; unsigned int n; check_free(obj); res = GetMysqlRes(obj); max = mysql_num_fields(res); n = NUM2INT(nr); if (n >= max) rb_raise(eMysql, "%d: out of range (max: %d)", n, max-1); #if MYSQL_VERSION_ID >= 32226 return make_field_obj(mysql_fetch_field_direct(res, n)); #else return make_field_obj(&mysql_fetch_field_direct(res, n)); #endif }
void key_tasklist_filter(const char* arg) { /* {{{ */ /* handle a keyboard direction to add a new filter * arg - string to filter by (pass NULL to prompt user) * see the manual page for how filter strings are parsed */ check_free(active_filter); if (arg == NULL) { statusbar_getstr(&active_filter, "filter by: "); wipe_statusbar(); } else { active_filter = strdup(arg); } /* force reload of task list */ statusbar_message(cfg.statusbar_timeout, "filter applied"); reload = true; } /* }}} */
/* fetch_lengths() */ static VALUE fetch_lengths(VALUE obj) { MYSQL_RES* res; unsigned int n; unsigned long* lengths; VALUE ary; unsigned int i; check_free(obj); res = GetMysqlRes(obj); n = mysql_num_fields(res); lengths = mysql_fetch_lengths(res); if (lengths == NULL) return Qnil; ary = rb_ary_new2(n); for (i=0; i<n; i++) rb_ary_store(ary, i, INT2NUM(lengths[i])); return ary; }
void alarm_handle_deliver(alarm_handle_t h, etime_t time) { alarm_handler_t handler ; env_t env ; assert_bool(h->live) ; assert(h->count > 0) ; if (h->live) { handler = h->upcall ; env = h->env ; assert(handler) ; } else { env = NULL ; handler = NULL ; } h->count -- ; check_free(h) ; if (handler) { handler(env, time) ; } }
void key_tasklist_search(const char* arg) { /* {{{ */ /* handle a keyboard direction to search * arg - the string to search for (pass NULL to prompt user) */ check_free(searchstring); if (arg == NULL) { /* store search string */ statusbar_getstr(&searchstring, "/"); wipe_statusbar(); } else { searchstring = strdup(arg); } /* go to first result */ find_next_search_result(head, get_task_by_position(selline)); tasklist_check_curs_pos(); redraw = true; } /* }}} */