예제 #1
0
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;
}
예제 #2
0
파일: list.c 프로젝트: guolilong2012/study
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;
}
예제 #3
0
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 );
}
예제 #4
0
void thread_impl_t::set_token( token_t *tok )
{
	if (token)
		release( token );
	addref( tok );
	token = tok;
}
예제 #5
0
void thread_impl_t::register_terminate_port( object_t *port )
{
	if (terminate_port)
		release(terminate_port);
	addref( port );
	terminate_port = port;
}
예제 #6
0
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;
}
예제 #7
0
파일: block.cpp 프로젝트: killvxk/ring3k
void mblock::set_section( object_t *s )
{
	if (section)
		release( section );
	section = s;
	addref( section );
}
예제 #8
0
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);
    }
}
예제 #9
0
파일: obs.hpp 프로젝트: Arkkis/obs-studio
	inline OBSRef &Replace(T valIn)
	{
		addref(valIn);
		release(val);
		val = valIn;
		return *this;
	}
예제 #10
0
파일: list.c 프로젝트: guolilong2012/study
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++;
}
예제 #11
0
static OSKIT_COMDECL_U
asyncio_addref(oskit_asyncio_t *f)
{
	struct char_queue_stream *s = (void *) (f - 1);

	return addref(&s->streami);
}
예제 #12
0
파일: umatrix.cpp 프로젝트: MCobias/opencv
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();
}
예제 #13
0
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 );
}
예제 #14
0
파일: list.c 프로젝트: guolilong2012/study
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;
}
예제 #15
0
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;
    }
}
예제 #16
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;
}
예제 #17
0
파일: list.c 프로젝트: guolilong2012/study
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;
}
예제 #18
0
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;
}
예제 #19
0
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;
}
예제 #20
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 );
		    }
		}
    }
}
예제 #21
0
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;
}
예제 #22
0
파일: objdir.cpp 프로젝트: killvxk/ring3k
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;
}
예제 #23
0
파일: list.c 프로젝트: guolilong2012/study
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);
}
예제 #24
0
파일: storage.c 프로젝트: welterde/NuMOO
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;
}
예제 #25
0
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;
}
예제 #26
0
파일: list.c 프로젝트: guolilong2012/study
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);
}
예제 #27
0
///Подсчёт ссылок
    void AddRef ()  { addref (this); }
예제 #28
0
파일: obs.hpp 프로젝트: Arkkis/obs-studio
	inline OBSRef(const OBSRef &ref) : val(ref.val) {addref(val);}
예제 #29
0
파일: obs.hpp 프로젝트: Arkkis/obs-studio
	inline OBSRef(T val_) : val(val_)               {addref(val);}
예제 #30
0
파일: list.c 프로젝트: guolilong2012/study
ADT list_data(List* self)
{
	RealList* l_reallist = (RealList*)self;

	return l_reallist->current? addref(ADT, l_reallist->current->data):NULL;
}