struct tref *addref(struct tref *node, char *key, int linenumber) { /* Add key to the node tree. * * If a key already exists in the node tree, add the line on which * it occurs to the occurrences tree for the given key. * * Returns: pointer to the node which was passed as an input argument. */ int cmp; if(!node) { node = (struct tref *)malloc(sizeof(struct tref)); node->key = strdup(key); node->left = node->right = NULL; node->lines = NULL; node->lines = addline(node->lines, linenumber); } else if((cmp = strcmp(key, node->key)) < 0) { node->left = addref(node->left, key, linenumber); } else if(cmp > 0) { node->right = addref(node->right, key, linenumber); } else { addline(node->lines, linenumber); } return node; }
ADT list_find_ref(List* self, EqualFunc p_func, ADT p_data) { RealList* l_reallist = (RealList*)self; ListNode* l_stand; l_stand = l_reallist->tail; while ( l_stand != NULL ) { if ( p_func ) { if ( (*p_func)(l_stand->data, p_data) ) { l_reallist->current = l_stand; return addref(ADT, l_stand->data); } } else { if ( l_stand->data == p_data ) { l_reallist->current = l_stand; return addref(ADT, l_stand->data); } } l_stand = l_stand->prev; } return NULL; }
thread_obj_wait_t::thread_obj_wait_t( thread_impl_t* t, sync_object_t* o): obj(o), thread(t) { addref(obj); obj->add_watch( this ); }
void thread_impl_t::set_token( token_t *tok ) { if (token) release( token ); addref( tok ); token = tok; }
void thread_impl_t::register_terminate_port( object_t *port ) { if (terminate_port) release(terminate_port); addref( port ); terminate_port = port; }
NTSTATUS symlink_opener::on_open( object_dir_t* dir, object_t*& obj, open_info_t& info ) { if (!obj) return STATUS_OBJECT_PATH_NOT_FOUND; addref( obj ); return STATUS_SUCCESS; }
void mblock::set_section( object_t *s ) { if (section) release( section ); section = s; addref( section ); }
void finc_run_string(FinC* self, unsigned char* str) { FinCNode* l_node; String* l_str; FinCParser* parser; parser = finc_parser_new(); finc_parser_set_env(parser, self->env); l_str = string_new_str(str); finc_parser_parser_string(parser, l_str); l_node = addref(FinCNode, parser->tree_root); unref(parser); if ( g_finc_context->error !=0 ) { printf("\t%d error founded, stopped...\n", g_finc_context->error); unref(l_node); return; } if (l_node) { finc_node_evaluate (l_node); unref (l_node); } }
inline OBSRef &Replace(T valIn) { addref(valIn); release(val); val = valIn; return *this; }
void list_insert_after(List* self, ADT p_data) { RealList* l_reallist = (RealList*)self; ListNode* l_node; l_node = list_new_node(); l_node->data = addref(ADT, p_data); if ( l_reallist->current ) { if ( l_reallist->current->next ) { l_node->prev = l_reallist->current->next; l_reallist->current->next->prev = l_node; } else {/*if the current node is tail*/ l_reallist->tail = l_node; } l_node->prev = l_reallist->current; l_reallist->current->next = l_node; } else {/*if the self is empty.*/ l_reallist->head = l_node; l_reallist->tail = l_node; } l_reallist->current = l_node; l_reallist->length++; }
static OSKIT_COMDECL_U asyncio_addref(oskit_asyncio_t *f) { struct char_queue_stream *s = (void *) (f - 1); return addref(&s->streami); }
void UMat::create(int d, const int* _sizes, int _type, UMatUsageFlags _usageFlags) { this->usageFlags = _usageFlags; int i; CV_Assert(0 <= d && d <= CV_MAX_DIM && _sizes); _type = CV_MAT_TYPE(_type); if( u && (d == dims || (d == 1 && dims <= 2)) && _type == type() ) { if( d == 2 && rows == _sizes[0] && cols == _sizes[1] ) return; for( i = 0; i < d; i++ ) if( size[i] != _sizes[i] ) break; if( i == d && (d > 1 || size[1] == 1)) return; } int _sizes_backup[CV_MAX_DIM]; // #5991 if (_sizes == (this->size.p)) { for(i = 0; i < d; i++ ) _sizes_backup[i] = _sizes[i]; _sizes = _sizes_backup; } release(); if( d == 0 ) return; flags = (_type & CV_MAT_TYPE_MASK) | MAGIC_VAL; setSize(*this, d, _sizes, 0, true); offset = 0; if( total() > 0 ) { MatAllocator *a = allocator, *a0 = getStdAllocator(); if (!a) { a = a0; a0 = Mat::getDefaultAllocator(); } try { u = a->allocate(dims, size, _type, 0, step.p, 0, usageFlags); CV_Assert(u != 0); } catch(...) { if(a != a0) u = a0->allocate(dims, size, _type, 0, step.p, 0, usageFlags); CV_Assert(u != 0); } CV_Assert( step[dims-1] == (size_t)CV_ELEM_SIZE(flags) ); } finalizeHdr(*this); addref(); }
thread_t::thread_t(process_t *p) : fiber_t( fiber_default_stack_size ), process( p ), MessageId(0), port(0), queue(0) { id = allocate_id(); addref( process ); process->threads.append( this ); }
ADT list_last(List* self) { RealList* l_reallist = (RealList*)self; if ( l_reallist->head )//if the self is not empty. { l_reallist->current = l_reallist->tail; return addref(ADT, l_reallist->current->data); } return NULL; }
int Twinamp2dsp::init(void) { if (!inited++ && mod->Init) { boost::unique_lock<boost::mutex> lock(mut); addref(); unsigned threadID; hThread = (HANDLE)_beginthreadex(NULL, 65536, threadProc, this, NULL, &threadID); while (!h) { cond.wait(lock); } return (h != (HWND) - 1) ? 1 : (h = NULL, 0); } else { return 0; } }
FinCStruct* finc_struct_new(String* p_name) { FinCStruct *self; self = (FinCStruct*)mem_new (sizeof(FinCStruct)); object_init_object (OBJECT (self), finc_struct_destroy); self->name = addref (String, p_name); self->hash_field = hash_table_new (string_hash, string_equal); self->size = 0; self->next_index = 0; return self; }
ADT list_next(List* self) { RealList* l_reallist = (RealList*)self; if ( l_reallist->current )//if the self is not empty. { if ( l_reallist->current->next ) { l_reallist->current = l_reallist->current->next; return addref(ADT, l_reallist->current->data); } } return NULL; }
nsresult nsPACMan::PostQuery(PendingPACQuery *query) { MOZ_ASSERT(!NS_IsMainThread(), "wrong thread"); if (mShutdown) { query->Complete(NS_ERROR_NOT_AVAILABLE, EmptyCString()); return NS_OK; } // add a reference to the query while it is in the pending list RefPtr<PendingPACQuery> addref(query); mPendingQ.insertBack(addref.forget().take()); ProcessPendingQ(); return NS_OK; }
int main(int argc, char **argv) { char word[MAXWORD]; int linenumber; struct tref *root = NULL; while((linenumber = getword(word, MAXWORD)) != EOF) { if(binsearch(word, stopwords, NKEYS) < 0) { root = addref(root, word, linenumber); } } printtree(root); return 0; }
void finc_run_script(FinC* self, unsigned char* filename) { FinCNode* l_node; FinCFunc* l_func; String* l_name; FinCData* data_return; FinCParser* parser; parser = finc_parser_new(); finc_parser_set_env(parser, self->env); finc_parser_parser_file(parser, filename); l_node = addref(FinCNode, parser->tree_root); unref(parser); if (l_node) { finc_node_evaluate (l_node); unref (l_node); if ( g_finc_context->error != 0 ) { printf("\t%d error founded.\n", g_finc_context->error); return ; } else { l_name = string_new (); string_set_str (l_name, "main"); l_func = finc_context_get_func (g_finc_context, l_name); unref (l_name); if (l_func) { data_return = finc_func_call (l_func, NULL); unref (l_func); unref (data_return); } else { printf ("Runtime Error:function 'main' not founded\n"); finc_context_error_inc( g_finc_context ); } } } }
NTSTATUS pipe_container_t::create_server( pipe_server_t *& pipe, ULONG max_inst ) { dprintf("creating pipe server\n"); if (max_inst != max_instances) return STATUS_INVALID_PARAMETER; if (num_instances >= max_instances ) return STATUS_ACCESS_DENIED; num_instances++; pipe = new pipe_server_t( this ); servers.append( pipe ); addref( this ); return STATUS_SUCCESS; }
NTSTATUS find_object_t::on_open( object_dir_t *dir, object_t*& obj, open_info_t& info ) { trace("find_object_t::on_open %pus %s\n", &info.path, obj ? "exists" : "doesn't exist"); if (!obj) return STATUS_OBJECT_NAME_NOT_FOUND; // hack until NtOpenSymbolicLinkObject is fixed if (dynamic_cast<symlink_t*>( obj ) != NULL && (info.Attributes & OBJ_OPENLINK)) { return STATUS_INVALID_PARAMETER; } addref( obj ); return STATUS_SUCCESS; }
ADT list_at(List* self, int p_index) { RealList* l_reallist = (RealList*)self; int i; if ( p_index <=0 || p_index > l_reallist->length ) { return NULL; } l_reallist->current = l_reallist->head; for ( i=0 ; i<p_index ; i++) { l_reallist->current = l_reallist->current->next; } return addref(ADT, l_reallist->current->data); }
char * str_dup(const char *s) { char *r; if (s == 0 || *s == '\0') { static char *emptystring; if (!emptystring) { emptystring = (char *) mymalloc(1, M_STRING); *emptystring = '\0'; } addref(emptystring); return emptystring; } else { r = (char *) mymalloc(strlen(s) + 1, M_STRING); /* NO MEMO HERE */ strcpy(r, s); } return r; }
NTSTATUS create_thread( thread_t **pthread, process_t *p, PCLIENT_ID id, CONTEXT *ctx, INITIAL_TEB *init_teb, BOOLEAN suspended ) { thread_impl_t *t = new thread_impl_t( p ); if (!t) return STATUS_INSUFFICIENT_RESOURCES; NTSTATUS r = t->create( ctx, init_teb, suspended ); if (r < STATUS_SUCCESS) { dprintf("releasing partially built thread\n"); release( t ); t = 0; } else { *pthread = t; // FIXME: does a thread die when its last handle is closed? addref( t ); t->get_client_id( id ); } return r; }
ADT list_take_current(List* self) { RealList* l_reallist = (RealList*)self; ListNode* l_stand; ADT rtn = NULL; if ( l_reallist->current == NULL )return NULL; l_stand = l_reallist->current; if ( l_stand->prev ) l_stand->prev->next = l_stand->next; else l_reallist->head = l_stand->next; if ( l_stand->next ) l_stand->next->prev = l_stand->prev; else l_reallist->tail = l_stand->prev; if ( l_stand->next )l_reallist->current = l_stand->next; else l_reallist->current = l_stand->prev; mem_destroy(l_stand); l_reallist->length--; return addref(ADT, rtn); }
///Подсчёт ссылок void AddRef () { addref (this); }
inline OBSRef(const OBSRef &ref) : val(ref.val) {addref(val);}
inline OBSRef(T val_) : val(val_) {addref(val);}
ADT list_data(List* self) { RealList* l_reallist = (RealList*)self; return l_reallist->current? addref(ADT, l_reallist->current->data):NULL; }