int single_logout(single_login_t *sl, single_logout_func_t cb, char *ip, int port, void *param) { if (sl == NULL) return -1; char ip_port[32]; single_login_info_t *node; snprintf(ip_port, sizeof(ip_port), "%s:%d", ip, port); single_logout_func_t logout_func = (cb == NULL) ? default_logout_func : cb; pthread_mutex_lock(&sl->mtx); if (dlist_entry(sl->list, cmp_ipport, (void *)ip_port, (void **)&node) == -1) { pthread_mutex_unlock(&sl->mtx); return -1; } if (--node->user_num <= 0) dlist_del(&sl->list, cmp_ipport, (void *)ip_port, logout_func, param); pthread_mutex_unlock(&sl->mtx); return 0; }
inline static void* __d_fp_malloc_from_list(struct fixed_dmem_pool* pool) { if(!DLIST_EMPTY(&pool->head)){ struct dlist_node* node = pool->head.next; dlist_del(node); return container_of(node, struct dmem_node, node); } return NULL; }
inline int hash_del(hash_table_t *table, void *data, ds_cmpfunc_t cmp, void *val, ds_callback_t cb, void *param) { unsigned int index; if (table == NULL) return -1; index = table->hashfunc(table->size, data); return dlist_del(&table->table[index], cmp, val, cb, param); }
static void free_i18n_strings(void) { struct dlist_head * entry; i18nstr_t * istr; while (!dlist_empty(&g_i18n_strings)) { entry = g_i18n_strings.next; dlist_del(entry); istr = dlist_entry(entry, i18nstr_t, list); if (istr->string) FREE(istr->string); FREE(istr); } }
static void close_chatbox(GtkWidget *widget, gpointer data) { chatbox_t *chatbox; ifreechat_t *ifc; GtkWidget *p; pthread_mutex_t *lock; chatbox = (chatbox_t*)data; ifc = (ifreechat_t*)chatbox->ifreechat; gtk_widget_destroyed(chatbox->window, &p); if (p != NULL) { gtk_widget_destroy(chatbox->window); } if (chatbox->type == PCHATBOX) { lock = &(ifc->pchatbox_lock); } else { lock = &(ifc->gchatbox_lock); } pthread_mutex_lock(lock); dlist_del(&(chatbox->chatbox_node)); pthread_mutex_unlock(lock); free(chatbox); }
static int fuse_fill_dentry(struct super_block *sb, char *dest) { struct dentry *d; struct lookup lookup; dvfs_lookup(dest, &lookup); if (lookup.item == NULL) return -ENOENT; assert(lookup.item->flags & S_IFDIR); if (!(lookup.item->flags & DVFS_DIR_VIRTUAL)) { /* Hide dentry of the directory */ dlist_del(&lookup.item->children_lnk); dvfs_cache_del(lookup.item); d = dvfs_alloc_dentry(); dentry_fill(sb, NULL, d, lookup.parent); strcpy(d->name, lookup.item->name); } else { d = lookup.item; /* TODO free related inode */ } d->flags |= S_IFDIR | DVFS_MOUNT_POINT; d->d_sb = sb, d->d_ops = sb ? sb->sb_dops : NULL, dentry_ref_inc(d); sb->root = d; d->d_inode = dvfs_alloc_inode(sb); *d->d_inode = (struct inode ) { .flags = S_IFDIR, .i_ops = sb->sb_iops, .i_sb = sb, .i_dentry = d, }; return 0; } static void *fuse_module_mount_process(void *arg) { struct fuse_mount_params *params; const struct cmd *cmd; struct super_block *sb; struct dumb_fs_driver *fs_drv; char *argv[3]; char argv0[0x20]; char argv1[0x20]; char argv2[0x20]; params = arg; cmd = cmd_lookup(params->fm->fuse_module_cmd_mount); assert(cmd); fs_drv = dumb_fs_driver_find(params->fm->fuse_module_cmd_mount); assert(fs_drv); strncpy(argv0, params->fm->fuse_module_cmd_mount, sizeof(argv0)); strncpy(argv1, params->dev, sizeof(argv1)); strncpy(argv2, params->dest, sizeof(argv2)); argv[0] = argv0; argv[1] = argv1; argv[2] = argv2; params->fm = NULL; sb = dvfs_alloc_sb(fs_drv, NULL); fuse_fill_dentry(sb, argv2); cmd_exec(cmd, 3, argv); /* will not return */ return NULL; } int fuse_module_mount(struct fuse_module *fm, char *dev, char *dest) { int res; struct fuse_mount_params params = {fm, dev, dest}; assert(fm); res = new_task(fm->fuse_module_cmd_mount, fuse_module_mount_process, ¶ms); if (res) { return res; } while (params.fm) { sleep(0); } return 0; }
void runq_remove(runq_t *queue, struct schedee *schedee) { dlist_del(&schedee->runq_link); }
void uart_deregister(struct uart *uart) { dlist_del(&uart->lnk); index_free(&serial_indexator, uart->idx); }
static inline void utlLog_queue_pop(UtlLogQueue *queue) { dlist_del(queue->list_head.next); }
void utlMem_free(void *buf) { UINT32 size; if (buf != NULL) { UINTPTR *intBuf = (UINTPTR *) (((UINTPTR) buf) - UTL_MEM_HEADER_LENGTH); #ifdef UTL_MEM_LEAK_TRACING { AllocRecord *allocRec; dlist_for_each_entry(allocRec, &glbAllocRec, dlist) if (allocRec->bufAddr == buf) break; if ((DlistNode *) allocRec != &glbAllocRec) { dlist_del((struct dlist_node *) allocRec); free(allocRec); } } #endif size = intBuf[1]; if (intBuf[1] != (intBuf[2] ^ UTL_MEM_HEADER_MASK)) { utlLog_error("memory underflow detected, %d %d", intBuf[1], intBuf[2]); utlAst_assert(0); return; } #ifdef UTL_MEM_DEBUG { UINT32 allocSize, intSize, roundupSize, i; UINT8 *charBuf = (UINT8 *) buf; allocSize = REAL_ALLOC_SIZE(intBuf[1]); intSize = allocSize / sizeof(UINTPTR); roundupSize = ROUNDUP(intBuf[1]); for (i=intBuf[1]; i < roundupSize; i++) { if (charBuf[i] != (UINT8) (UTL_MEM_FOOTER_PATTERN & 0xff)) { utlLog_error("memory overflow detected at idx=%d 0x%x 0x%x 0x%x", i, charBuf[i], intBuf[intSize-1], intBuf[intSize-2]); utlAst_assert(0); return; } } if ((intBuf[intSize - 1] != UTL_MEM_FOOTER_PATTERN) || (intBuf[intSize - 2] != UTL_MEM_FOOTER_PATTERN)) { utlLog_error("memory overflow detected, 0x%x 0x%x", intBuf[intSize - 1], intBuf[intSize - 2]); utlAst_assert(0); return; } #ifdef UTL_MEM_POISON_ALLOC_FREE /* * write garbage into buffer which is about to be freed to detect * users of freed buffers. */ memset(intBuf, UTL_MEM_FREE_PATTERN, allocSize); #endif } #endif /* UTL_MEM_DEBUG */ buf = intBuf; /* buf points to real start of buffer */ osl_free(buf); mStats.bytesAllocd -= size; mStats.numFrees++; }