/* * Decrement reference count on a dreg entry. If ref count goes to * zero, don't free it, but put it on the unused list so we * can evict it if necessary. Put on head of unused list. */ void dreg_decr_refcount(dreg_entry * d) { void *buf; aint_t bufint; assert(d->refcount > 0); d->refcount--; if (d->refcount == 0) { if(viadev_use_dreg_cache) { DREG_ADD_TO_UNUSED_LIST(d); } else { bufint = d->pagenum << DREG_PAGEBITS; buf = (void *) bufint; d->is_valid = 0; if (deregister_memory(d->memhandle)) { error_abort_all(IBV_RETURN_ERR, "deregister fails\n"); } d->memhandle = NULL; dreg_remove (d); DREG_ADD_TO_FREE_LIST(d); } } T_PRINT("decr_refcount: entry " AINT_FORMAT " refcount" AINT_FORMAT " memhandle" AINT_FORMAT, (aint_t) d, (aint_t) d->refcount, (aint_t) d->memhandle); }
void print_line_on_shell(t_shprop *shell, char *line) { t_term *term; char to_print; int i; term = shell->term; i = 0; while (line[i]) { to_print = line[i]; if (ft_isprint(to_print)) { ft_putchar_fd(to_print, shell->term->fd); shell->curs_pos = (int)shell->input_len; } i++; } if ((shell->curs_pos + shell->prompt_len) % shell->term->ws.ws_col == 0) { T_PRINT(" "); key_move_left(shell); key_move_right(shell); } }
void add_char_input(t_shprop *shell, int key) { t_term *term; term = shell->term; if (ft_isprint(key)) { ft_putchar_fd(key, term->fd); shell->input_len++; cur_pos_char_insert(shell, key); if (shell->hist && !shell->hist->prev) ft_str_renew(&(shell->hist)->line, ft_strdup(shell->input)); shell->curs_pos++; if (shell->curs_pos >= (int)shell->input_len) if ((shell->curs_pos + shell->prompt_len) % term->ws.ws_col == 0) { T_PRINT(" "); key_move_left(shell); key_move_right(shell); } if (shell->input_len + shell->prompt_len > term->ws.ws_col && shell->curs_pos < (int)shell->input_len) fill_lines(shell); } }
dreg_entry *dreg_get() { dreg_entry *d; DREG_GET_FROM_FREE_LIST(d); if (d != NULL) { d->refcount = 0; d->next_unused = NULL; d->prev_unused = NULL; d->next = NULL; } else { T_PRINT("dreg_get: no free dreg entries"); } return (d); }