void after_connected() { // when retrying, pool will be non-null because we reuse it if(!udp && !pool) { pool = new StunTransactionPool(StunTransaction::Tcp, this); connect(pool, SIGNAL(outgoingMessage(const QByteArray &, const QHostAddress &, int)), SLOT(pool_outgoingMessage(const QByteArray &, const QHostAddress &, int))); connect(pool, SIGNAL(needAuthParams()), SLOT(pool_needAuthParams())); pool->setLongTermAuthEnabled(true); if(!user.isEmpty()) { pool->setUsername(user); pool->setPassword(pass); if(!realm.isEmpty()) pool->setRealm(realm); } } allocate = new StunAllocate(pool); connect(allocate, SIGNAL(started()), SLOT(allocate_started())); connect(allocate, SIGNAL(stopped()), SLOT(allocate_stopped())); connect(allocate, SIGNAL(error(XMPP::StunAllocate::Error)), SLOT(allocate_error(XMPP::StunAllocate::Error))); connect(allocate, SIGNAL(permissionsChanged()), SLOT(allocate_permissionsChanged())); connect(allocate, SIGNAL(channelsChanged()), SLOT(allocate_channelsChanged())); allocate->setClientSoftwareNameAndVersion(clientSoftware); allocateStarted = false; emit q->debugLine("Allocating..."); allocate->start(); }
static void synchronize(struct wdgt *w) { int l = 0; struct proc_t *p = tree_start(tree_root, tree_root); struct process **current = &begin, *z; while(p){ if (*current && p->priv){ (*current)->line = l++; (*current)->proc->priv = *current; p = tree_next(); current = &((*current)->next); continue; } z = malloc(sizeof *z); if (!z) allocate_error(); //allocated++; // proc_win.d_lines++; memset(z, 0, sizeof *z); scr_linserted(w, l); z->line = l++; p->priv = z; z->proc = p; pstat_update(z, 1); if (*current){ z->next = *current; (*current)->prev = &z->next; } *current = z; z->prev = current; current = &(z->next); p = tree_next(); } }
void pool::deallocate(index_type index) { if (!owns(index)) throw allocate_error(allocate_errc::invalid_ptr); *(index_type*)pointer(index) = index_type(head_); head_ = index; nfree_++; }
void pool::initialize(void* memory, size_type bytes, size_type block_size) { if (!memory) throw allocate_error(allocate_errc::invalid_bookkeeping); if (block_size < sizeof(index_type)) throw allocate_error(allocate_errc::invalid_block_size); const size_type capacity = calc_capacity(bytes, block_size); if (!capacity || capacity > max_capacity()) throw allocate_error(allocate_errc::invalid_bookkeeping); blocks_ = (uint8_t*)memory; stride_ = block_size; nblocks_ = capacity; nfree_ = capacity; head_ = 0; const index_type n = nblocks_ - 1; for (index_type i = 0; i < n; i++) *(index_type*)(stride_ * i + blocks_) = i + 1; *(index_type*)(stride_ * n + blocks_) = nullidx; }
static struct owner* new_owner(int n) { struct owner* p; struct passwd *u; p = (struct owner*) malloc(sizeof *p); if (!p) allocate_error(); memset(p, 0, sizeof *p); u = getpwuid(n); if (!u) sprintf(p->name, "%d", n); else { strncpy(p->name, u->pw_name, NAME_SIZE); p->name[NAME_SIZE] = 0; } p->uid = n; list_add(hash_table[hash_fun(n)], p); return p; }