/* add to the argv list for the helper processes */ void helper_save_arg(const char *flag, const char *value) { char const **new_arg; int i; if (helper.free_args <= 1) { /* reserve space for the argv[0] and the null terminator */ helper.free_args += 5; i = (helper.argc + 2*helper.free_args) * sizeof(char *); new_arg = dcc_malloc(i); memset(new_arg, 0, i); if (helper.argv) { for (i = 0; i < helper.argc; ++i) new_arg[i] = helper.argv[i]; dcc_free(helper.argv); } else { ++helper.argc; } helper.argv = new_arg; } helper.argv[helper.argc] = flag; helper.argv[++helper.argc] = value; helper.argv[++helper.argc] = 0; --helper.free_args; }
static void id_tbl_expand_hash(u_char debug) { u_int old_bins; ID_TBL *tp, **old_bin, **old_hash; double rate; old_hash = id_tbl_hash; old_bins = id_tbl_bins; id_tbl_bins += max(16, old_bins/8); if (id_tbl_bins < id_tbl_blocks/8) id_tbl_bins = id_tbl_blocks/8; id_tbl_bins = hash_divisor(id_tbl_bins, 0); id_tbl_hash = dcc_malloc(id_tbl_bins*sizeof(*id_tbl_hash)); if (!id_tbl_hash) dcc_logbad(EX_OSERR, "malloc(%d ID hash table) failed", id_tbl_bins); memset(id_tbl_hash, 0, id_tbl_bins*sizeof(ID_TBL *)); if (old_hash) { if (debug) { rate = id_probes; if (id_searches != 0) rate /= id_searches; dcc_trace_msg("increase from %d to %d ID bins for" " %d blocks; average search length %.1f", old_bins, id_tbl_bins, id_tbl_blocks, rate); } /* copy the active blocks to the new hash table of bins */ for (old_bin = &old_hash[0]; old_bin < &old_hash[old_bins]; ++old_bin) { while ((tp = *old_bin) != 0) { *old_bin = tp->hfwd; tp->hbak = 0; tp->hfwd = 0; id_tbl_link(tp, &ID_HASH_ENTRY(tp->id)); } } dcc_free(old_hash); } id_probes = 0; id_searches = 0; }
/******************************************************************** NICKS_REMOVE Fjerner en person fra nicks arrayen og free'er alle resourcer som er associeret med den personen Parameter og return: [in] long index = personens numeric [in] long numeric = personens numeric [out] long return < 0 = Fejl >= 0 = OK ********************************************************************/ long nicks_remove(const char *numeric) { long nr, index, i; if ((index = nicks_search_numeric(numeric)) < 0) return index; if ((nr = nicks_search_nick(nicks_num[index]->nick)) < 0) return nr; for (i = nicks[nr]->channels_count; i > 0; i--) { if (channels_userpart(-1, nicks[nr]->channels[i-1]->channel->name, nicks[nr]->numeric) < 0) { debug_out("We're f****d !!!! - %lu %s\n", nicks[nr]->channels_count, nicks[nr]->channels[0]->channel->name); log_command(LOG_SERVICES, NULL, "", "BUG! nicks_remove - %lu %s", nicks[nr]->channels_count, nicks[nr]->channels[0]->channel->name); } } if (nicks[nr]->channels_count) { debug_out("WARNING !!!! Memory leak - not all channels was parted in memory (%lu)!!!!\n", nicks[nr]->channels_count); } dcc_free(nicks[nr]); if (nicks[nr]) { if (nicks[nr]->nickserv) nicks[nr]->nickserv->entry = NULL; xfree(nicks[nr]->nick); xfree(nicks[nr]->numeric); xfree(nicks[nr]->username); xfree(nicks[nr]->host); xfree(nicks[nr]->userinfo); xfree(nicks[nr]->away); xfree(nicks[nr]); } nicks_count--; memmove(&nicks[nr], &nicks[nr+1], (nicks_count - nr) * sizeof(dbase_nicks*)); nicks = (dbase_nicks**)realloc(nicks, nicks_count * sizeof(dbase_nicks*)); memmove(&nicks_num[index], &nicks_num[index+1], (nicks_count - index) * sizeof(dbase_nicks*)); nicks_num = (dbase_nicks**)realloc(nicks_num, nicks_count * sizeof(dbase_nicks*)); return index; }