本文整理汇总了C++中remove_from_list函数的典型用法代码示例。如果您正苦于以下问题:C++ remove_from_list函数的具体用法?C++ remove_from_list怎么用?C++ remove_from_list使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了remove_from_list函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: remove_shader_variant
static void
remove_shader_variant(struct llvmpipe_context *lp,
struct lp_fragment_shader_variant *variant)
{
struct llvmpipe_screen *screen = llvmpipe_screen(lp->pipe.screen);
unsigned i;
if (gallivm_debug & GALLIVM_DEBUG_IR) {
debug_printf("llvmpipe: del fs #%u var #%u v created #%u v cached #%u v total cached #%u\n",
variant->shader->no, variant->no, variant->shader->variants_created,
variant->shader->variants_cached, lp->nr_fs_variants);
}
for (i = 0; i < Elements(variant->function); i++) {
if (variant->function[i]) {
if (variant->jit_function[i])
LLVMFreeMachineCodeForFunction(screen->engine,
variant->function[i]);
LLVMDeleteFunction(variant->function[i]);
}
}
remove_from_list(&variant->list_item_local);
variant->shader->variants_cached--;
remove_from_list(&variant->list_item_global);
lp->nr_fs_variants--;
FREE(variant);
}
示例2: free_mud_event
void free_mud_event(struct mud_event_data *pMudEvent)
{
struct descriptor_data * d;
struct char_data * ch;
switch (mud_event_index[pMudEvent->iId].iEvent_Type) {
case EVENT_WORLD:
remove_from_list(pMudEvent->pEvent, world_events);
break;
case EVENT_DESC:
d = (struct descriptor_data *) pMudEvent->pStruct;
remove_from_list(pMudEvent->pEvent, d->events);
break;
case EVENT_CHAR:
ch = (struct char_data *) pMudEvent->pStruct;
remove_from_list(pMudEvent->pEvent, ch->events);
break;
}
if (pMudEvent->sVariables != NULL)
free(pMudEvent->sVariables);
pMudEvent->pEvent->event_obj = NULL;
free(pMudEvent);
}
示例3: GET_PREVALLOC
/**
* coalesce - Concatenate adjacent blocks to prevent fragmentation.
*
* Should upkeep the free list. Assumes that bp is a free block.
* Also assumes that bp has not yet been added to a free list.
*/
static void *coalesce(void *bp)
{
size_t prev_alloc = GET_PREVALLOC(bp);
size_t next_alloc = GET_NEXTALLOC(bp);
size_t size = GET_THISSIZE(bp);
char *next_block = GET_NEXTBLOCK(bp);
char *prev_block = GET_PREVBLOCK(bp);
TRACE(">>>Entering coalesce(bp=0x%X)\n", (unsigned int)bp);
/* Case 1, Both blocks allocated, does not need its own if statement */
if (prev_alloc && !next_alloc) { /* Case 2: only next_block is free */
remove_from_list(next_block, calc_list_index(GET_THISSIZE(next_block)));
/* Only need to update the size field */
size += GET_SIZE(GET_BLOCKHDR(next_block));
PUTW(GET_BLOCKHDR(bp), PACK(size, prev_alloc));
PUTW(GET_BLOCKFTR(bp), PACK(size, prev_alloc));
}
else if (!prev_alloc && next_alloc) { /* Case 3: only prev_block is free */
remove_from_list(prev_block, calc_list_index(GET_THISSIZE(prev_block)));
/* Need to update the size and prev_alloc field */
size += GET_THISSIZE(prev_block);
prev_alloc = GET_PREVALLOC(prev_block);
PUTW(GET_BLOCKFTR(bp), PACK(size, prev_alloc));
PUTW(GET_BLOCKHDR(prev_block), PACK(size, prev_alloc));
bp = prev_block;
}
else if (!prev_alloc && !next_alloc) { /* Case 4: Both blocks are free */
remove_from_list(next_block, calc_list_index(GET_THISSIZE(next_block)));
remove_from_list(prev_block, calc_list_index(GET_THISSIZE(prev_block)));
/* Need to update the size and prev_alloc field */
size += GET_THISSIZE(prev_block) + GET_THISSIZE(next_block);
prev_alloc = GET_PREVALLOC(prev_block);
PUTW(GET_BLOCKHDR(GET_PREVBLOCK(bp)), PACK(size, prev_alloc));
PUTW(GET_BLOCKFTR(GET_NEXTBLOCK(bp)), PACK(size, prev_alloc));
bp = GET_PREVBLOCK(bp);
}
/* coalesce() is always called after a block is marked free
so it needs to add the block to the appropriate free list */
add_to_list(bp, calc_list_index(size));
TRACE("<<<---Leaving coalesce()\n");
return bp;
}
示例4: main
int main()
{
printf("Testing lists...\n");
List *list = (List *) create_list();
assert(list != NULL);
assert(list->data == NULL);
assert(list->next == NULL);
int w = 42;
int x = 1;
int y = 2;
int z = 3;
append_to_list(list, &x);
assert(*(int *)(list->data) == 1);
assert(list->next != NULL);
append_to_list(list, &y);
assert(*(int *)(list->next->data) == 2);
assert(list->next->next != NULL);
append_to_list(list, &z);
assert(*(int *)(list->next->next->data) == 3);
assert(list->next->next->next != NULL);
assert(list->next->next->next->data == NULL);
assert(list->next->next->next->next == NULL);
list = (List *) push_to_list(list, &w);
assert(*(int *)(list->data) == 42);
assert(list->next != NULL);
list = (List *) pop_from_list(list);
assert(*(int *)(list->data) == 1);
assert(list_length(list) == 3);
assert(list_index(list, &y) == 1);
assert(list_index(list, &w) == -1);
list = remove_from_list(list, &x);
assert(*(int *)(list->data) == 2);
list = push_to_list(list, &x);
list = remove_from_list(list, &y);
assert(*(int *)(list->next->data) == 3);
printf("List tests passed\n");
return 0;
}
示例5: allocate_page
/*
* Allocates a page off one of our lists.
*
* Parameters:
* - uiFlags = Flags for the page allocation.
*
* Returns:
* INVALID_PAGE if the page could not be allocated, otherwise the index of the allocated page.
*/
static UINT32 allocate_page(UINT32 uiFlags)
{
UINT32 rc;
PPAGELIST ppgl = NULL;
BOOL bZero = FALSE;
if (uiFlags & PGALLOC_ZERO)
{ /* try zeroed list first, then free (but need to zero afterwards) */
if (g_pglZeroed.cpg > 0)
ppgl = &g_pglZeroed;
else if (g_pglFree.cpg > 0)
{
ppgl = &g_pglFree;
bZero = TRUE;
}
}
else
{ /* try free list first, then zeroed */
if (g_pglFree.cpg > 0)
ppgl = &g_pglFree;
else if (g_pglZeroed.cpg > 0)
ppgl = &g_pglZeroed;
}
/* TODO: apply additional strategy if we don't yet have a page list */
if (!ppgl)
return INVALID_PAGE;
rc = g_pMasterPageDB[ppgl->ndxLast].d.next; /* take first page on list */
remove_from_list(ppgl, rc);
if (bZero)
zero_page(rc);
return rc;
}
示例6: flush_page
void bin_index_t::file_node::remove_oldest()
{
for(page_wptr wp=last_page;pages.size()>=max_pages&&!wp.expired();)
{
page_ptr r;
page_ptr l;
{
page_ptr p=wp.lock();
r=p->right.lock();
l=p->left.lock();
flush_page(*p);
pages.erase(p->page_offset);
remove_from_list(p);
}
//Somebody still use this page and we can't delete it
if(!wp.expired())
{
page_ptr p=wp.lock();
pages[p->page_offset]=p;
insert_into_list(p,r);
}
wp=l;
}
}
示例7: llvmpipe_resource_destroy
static void
llvmpipe_resource_destroy(struct pipe_screen *pscreen,
struct pipe_resource *pt)
{
struct llvmpipe_screen *screen = llvmpipe_screen(pscreen);
struct llvmpipe_resource *lpr = llvmpipe_resource(pt);
if (lpr->dt) {
/* display target */
struct sw_winsys *winsys = screen->winsys;
winsys->displaytarget_destroy(winsys, lpr->dt);
}
else if (llvmpipe_resource_is_texture(pt)) {
/* free linear image data */
if (lpr->linear_img.data) {
align_free(lpr->linear_img.data);
lpr->linear_img.data = NULL;
}
}
else if (!lpr->userBuffer) {
assert(lpr->data);
align_free(lpr->data);
}
#ifdef DEBUG
if (lpr->next)
remove_from_list(lpr);
#endif
FREE(lpr);
}
示例8: Free
void Free(void *ptr)
#endif
{
if (ptr != NULL) {
#ifdef MEMORY_DEBUG
memory_block *block_ptr = NULL;
block_ptr = (memory_block*)(void*)((unsigned char*)ptr - offset);
#ifdef MEMORY_DEBUG_ADDRESS
check_memory_address(block_ptr, 2);
#endif
check_magic_values(filename, line, block_ptr, 0);
remove_from_list(block_ptr);
allocated_size -= block_ptr->size;
memset(ptr, 0xAA, block_ptr->size);
#ifdef MEMORY_DEBUG_FREE
add_to_free_list(block_ptr);
#else
free(block_ptr);
#endif
#else
free(ptr);
#endif
free_count++;
}
}
示例9: malloc
char *sort_list(char *inlist, int inlist_size) {
char *tmplist;
char tmp[IFNAMSIZ];
if (!inlist_size) return NULL;
if (!inlist) return NULL;
tmplist = (char *) malloc(inlist_size);
if (!tmplist) return NULL;
memset(tmplist, 0, inlist_size);
char *b;
int len;
while ((b = find_smallest_in_list(inlist)) != NULL) {
len = strcspn(b, " ");
snprintf(tmp, len + 1, "%s", b);
add_to_list(tmp, tmplist, inlist_size);
remove_from_list(tmp, inlist, inlist_size);
}
strncpy(inlist, tmplist, inlist_size);
free(tmplist);
return inlist;
}
示例10: clean_up_unknown
void clean_up_unknown()
{
if(verbose_lvl)
cout << indent(2) << "Cleaning up invalid hosts." << endl;
// create a list of all links from an unknown to a node, and a list of
// links from a node to an unkown and store them in a map
LinkMap to_u;
LinkMap from_u;
fill_maps(network, to_u, from_u);
// give all members of an non-empty intersection, of two elements of both
// maps, the same name
for(LinkMap_iter to_iter = to_u.begin(); to_iter != to_u.end(); to_iter++)
for(LinkMap_iter from_iter = from_u.begin(); from_iter != from_u.end();
from_iter++)
if(to_iter->first->name() != from_iter->first->name()) {
HostPList hl = intersect(to_iter->second, from_iter->second);
if(!hl.empty())
equilize_names(network, hl);
}
// clean up trash
remove_from_list(hostlist, trash);
network.sort();
network.unique();
}
示例11: leave_group
void leave_group(struct char_data *ch)
{
struct group_data *group;
struct char_data *tch;
struct iterator_data Iterator;
bool found_pc = FALSE;
if ((group = ch->group) == NULL)
return;
send_to_group(NULL, group, "%s has left the group.\r\n", GET_NAME(ch));
remove_from_list(ch, group->members);
ch->group = NULL;
if (group->members->iSize) {
for (tch = (struct char_data *) merge_iterator(&Iterator, group->members);
tch; tch = next_in_list(&Iterator))
if (!IS_NPC(tch))
found_pc = TRUE;
remove_iterator(&Iterator);
}
if (!found_pc)
SET_BIT(GROUP_FLAGS(group), GROUP_NPC);
if (GROUP_LEADER(group) == ch && group->members->iSize) {
group->leader = (struct char_data *) random_from_list(group->members);
send_to_group(NULL, group, "%s has assumed leadership of the group.\r\n", GET_NAME(GROUP_LEADER(group)));
} else if (group->members->iSize == 0)
free_group(group);
}
示例12: allocate
/**
* allocate - Place block, i.e. write header and footer.
*/
static void allocate(void *bp, size_t adjusted_size)
{
size_t csize = GET_THISSIZE(bp);
size_t is_prev_alloc = GET_PREVALLOC(bp);
TRACE(">>>Entering allocate(bp=0x%X, adjusted_size=%u)\n", (unsigned int)bp, adjusted_size);
/* We will always need to remove tshi block from the free list */
remove_from_list(bp, calc_list_index(csize));
/* See if there's room to split this block into two */
if ((csize - adjusted_size) >= (MIN_SIZE)) {
PUTW(GET_BLOCKHDR(bp), PACK(adjusted_size, THISALLOC | is_prev_alloc));
PUTW(GET_BLOCKFTR(bp), PACK(adjusted_size, THISALLOC | is_prev_alloc));
/* Using the new header info, mark the newly created block as free */
bp = GET_NEXTBLOCK(bp);
PUTW(GET_BLOCKHDR(bp), PACK(csize - adjusted_size, PREVALLOC));
PUTW(GET_BLOCKFTR(bp), PACK(csize - adjusted_size, PREVALLOC));
/* And add it to the appropriate free list */
coalesce(bp);
}
else {/* If there's not room to create split the block, just extend the
amount to allocated */
PUTW(GET_BLOCKHDR(bp), PACK(csize, THISALLOC | is_prev_alloc));
PUTW(GET_BLOCKFTR(bp), PACK(csize, THISALLOC | is_prev_alloc));
/* Make sure the next block's header has the prevalloc field marked */
bp = GET_BLOCKHDR(GET_NEXTBLOCK(bp));
PUTW(bp, GETW(bp) | PREVALLOC);
}
TRACE("<<<---Leaving allocate()\n");
}
示例13: main
int main(int argc, const char *argv[])
{
TContact_list contact_list = {contact_list.first = NULL, contact_list.last = NULL};
get_dir();
switch(get_mode(argc, argv)){
case DEL:
get_data(&contact_list);
remove_from_list(&contact_list, atoi(argv[2]));
save_csv(&contact_list);
generate_html(&contact_list);
free_list(&contact_list);
break;
case ADD:
get_data(&contact_list);
add_to_list(argv, &contact_list);
sort_list(&contact_list);
save_csv(&contact_list);
generate_html(&contact_list);
free_list(&contact_list);
break;
case LIST:
get_data(&contact_list);
sort_list(&contact_list);
print_list(&contact_list);
save_csv(&contact_list);
generate_html(&contact_list);
free_list(&contact_list);
break;
case SIN:
get_data(&contact_list);
print_single(&contact_list, atoi(argv[2]));
free_list(&contact_list);
break;
case FIND:
get_data(&contact_list);
find_in_list(&contact_list, (char *)argv[2]);
generate_html(&contact_list);
free_list(&contact_list);
break;
case PLIST:
get_data(&contact_list);
sort_list(&contact_list);
generate_plist(&contact_list);
free_list(&contact_list);
break;
case DELN:
get_data(&contact_list);
delete_by_name(&contact_list, (char *)argv[2], (char *)argv[3]);
save_csv(&contact_list);
generate_html(&contact_list);
free_list(&contact_list);
default:
handle_errors();
return EXIT_FAILURE;
}
if(handle_errors() != EXIT_SUCCESS) return EXIT_FAILURE;
else return EXIT_SUCCESS;
}
示例14: free_funcs
static void free_funcs( struct _tnl_dynfn *l )
{
struct _tnl_dynfn *f, *tmp;
foreach_s (f, tmp, l) {
remove_from_list( f );
ALIGN_FREE( f->code );
FREE( f );
}
示例15: policy_page_unmapped
/* This function is called when the virtual memory system unmaps a page from
* the virtual address space. Remove the page from the list of resident
* pages.
*/
void policy_page_unmapped(page_t page) {
pageinfo_t *pginfo, *prev;
pginfo = find_page(&pagelist, page, &prev);
assert(pginfo != NULL);
remove_from_list(&pagelist, pginfo, prev);
}