/* #Nombre: genera_cuadruplo_terminos #Descripcion: Genera el cuadruplo para sumar o restar. Las acciones realizadas en esta funcion son las que se llevan a cabo en genera_cuadruplo_factores */ void genera_cuadruplo_terminos(){ if(!g_queue_is_empty(p_operadores)){ int oper = GPOINTER_TO_INT(g_queue_peek_tail(p_operadores)); if(oper == o_suma || oper == o_resta){ g_queue_pop_tail(p_operadores); int tipo2 = GPOINTER_TO_INT(g_queue_pop_tail(p_tipos)); int tipo1 = GPOINTER_TO_INT(g_queue_pop_tail(p_tipos)); int tipo_resultado = cubo[oper][tipo1][tipo2]; if(tipo_resultado != -1){ int operando2 = GPOINTER_TO_INT(g_queue_pop_tail(p_operandos)); int operando1 = GPOINTER_TO_INT(g_queue_pop_tail(p_operandos)); int resultado; if(tipo_resultado == 4) resultado = asigna_dir(s_temporal, d_string); else resultado = asigna_dir(s_temporal, tipo_resultado); g_queue_push_tail(p_operandos, GINT_TO_POINTER(resultado)); g_queue_push_tail(p_tipos, GINT_TO_POINTER(tipo_resultado)); insertar_cuadruplo(oper, operando1, operando2, resultado); } else{ printf("Error en linea %d: Sumas y restas no pueden ser realizadas entre estos tipos de datos\n", yylineno); exit(EXIT_FAILURE); } } } }
/* Asserts that all files in @included are also in @including */ static void scan_directory (GFile *directory, FileScannedCallback scanned_callback, gpointer callback_data) { GQueue *files; GQueue *file_infos; GFileEnumerator *enumerator; files = g_queue_new (); file_infos = g_queue_new (); g_queue_push_tail (files, g_object_ref (directory)); g_queue_push_tail (file_infos, g_file_query_info (directory, G_FILE_ATTRIBUTE_STANDARD_NAME"," G_FILE_ATTRIBUTE_STANDARD_TYPE, G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, NULL, NULL)); while (!g_queue_is_empty (files)) { g_autoptr (GFile) file; g_autoptr (GFileInfo) file_info; file = g_queue_pop_tail (files); file_info = g_queue_pop_tail (file_infos); if (scanned_callback) { scanned_callback (file, file_info, callback_data); } if (g_file_info_get_file_type (file_info) == G_FILE_TYPE_DIRECTORY) { enumerator = g_file_enumerate_children (file, G_FILE_ATTRIBUTE_STANDARD_NAME"," G_FILE_ATTRIBUTE_STANDARD_TYPE, G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, NULL, NULL); if (enumerator) { GFile *child; GFileInfo *child_info; child_info = g_file_enumerator_next_file (enumerator, NULL, NULL); while (child_info != NULL) { child = g_file_get_child (file, g_file_info_get_name (child_info)); g_queue_push_tail (files, child); g_queue_push_tail (file_infos, child_info); child_info = g_file_enumerator_next_file (enumerator, NULL, NULL); } g_object_unref (enumerator); } } } g_queue_free_full (files, g_object_unref); g_queue_free_full (file_infos, g_object_unref); }
/* #Nombre: genera_cuadruplo_asignacion #Descripcion: Genera el cuadruplo para realizar una asignacion entre dos direcciones */ void genera_cuadruplo_asignacion(){ //Regresa el operador que se encuentra en el tope de la pila de tipos. int oper = GPOINTER_TO_INT(g_queue_peek_tail(p_operadores)); //Verifica si se trata de una asignacion if( oper == o_iguala ){ //Quita el operador de la pila de operadores g_queue_pop_tail(p_operadores); //Accesa, de la pila de tipos, los tipos de los datos que se van a utilizar en la asignacion int tipo2 = GPOINTER_TO_INT(g_queue_pop_tail(p_tipos)); int tipo1 = GPOINTER_TO_INT(g_queue_pop_tail(p_tipos)); //Verifica con el cubo de operaciones si la asignacion puede ser realizada entre el tipo de datos involucrados int tipo_resultado = cubo[oper][tipo1][tipo2]; if(tipo_resultado != -1){ //Saca los operandos involucrados de la pila de operandos int operando2 = GPOINTER_TO_INT(g_queue_pop_tail(p_operandos)); int operando1 = GPOINTER_TO_INT(g_queue_pop_tail(p_operandos)); //Genera cuadruplo para la asignacion insertar_cuadruplo(oper, operando2, -1, operando1); } else{ printf("Error en linea %d: Asignaciones no pueden ser realizadas entre estos tipos de datos\n", yylineno); exit(EXIT_FAILURE); } } }
/* #Nombre: genera_cuadruplo_lectura #Descripcion: Genera el cuadruplo para leer una variable #Parametros: const char *funcion, const char *id, int con_mensaje */ void genera_cuadruplo_lectura(const char *funcion, const char *id, int con_mensaje){ //Accesa la variable dentro de la funcion especificada y verifica si ha sido declarada Funcion *f = g_slice_new(Funcion); f = (Funcion*)g_hash_table_lookup(funciones, (gpointer)funcion); Variable *var = (Variable*)g_hash_table_lookup(f->variables, (gpointer)id); if(var == NULL){ printf("Error en linea %d: La variable \"%s\" no ha sido declarada\n", yylineno, id); exit(EXIT_FAILURE); } else{ //Se verifica si la lectura va a desplegar un mensaje int mensaje; if(con_mensaje){ int aux = GPOINTER_TO_INT(g_queue_pop_tail(p_tipos)); if(aux != d_string){ printf("Error en linea %d: El mensaje debe de ser TEXTO\n", yylineno, id); exit(EXIT_FAILURE); } mensaje = GPOINTER_TO_INT(g_queue_pop_tail(p_operandos)); } else{ mensaje = -1; } //Insertar cuadruplo para la lectura insertar_cuadruplo(INPUT,mensaje,-1,var->dir); } }
void Reset(STATE* state) { TETRAD* tetrad; size_t X = 0; state->status = STATUS_GAME; state->ticks = 0; state->speed = state->init_speed; state->level = state->init_level; state->lines = 0; state->score = 0; state->line_clear_t = 0; state->line_clear_f = 0; state->game_over_f = 0; state->pause_f = 0; for(X = 0; X < state->Bx * state->By; X++) { state->field[X] = 0; } while((tetrad = g_queue_pop_tail(state->queue))) TetradFree(tetrad); // push several new tetrads onto the stack while (g_queue_get_length(state->queue) < state->queue_size + 1) TetradQueue(state); state->tetrad = g_queue_pop_tail(state->queue); return; }
void fs_emu_stat_queue_add_entry(fs_emu_stat_queue* stat_queue, int data, int threshold) { if (stat_queue->queue == NULL) { fs_log("fs_emu_stat_queue_add_entry: queue is null"); return; } if (stat_queue->clear) { for (int i = 0; i < stat_queue->max_count; i++) { g_queue_push_head(stat_queue->queue, GINT_TO_POINTER(0)); g_queue_pop_tail(stat_queue->queue); } stat_queue->count = 0; stat_queue->total = 0; stat_queue->clear = 0; } /* if (treshold && abs(data) >= treshold) { return; } */ //fs_log("add %d\n", data); g_queue_push_head(stat_queue->queue, GINT_TO_POINTER(data)); int last = GPOINTER_TO_INT(g_queue_pop_tail(stat_queue->queue)); // fixme: min and max stat_queue->total += data - last; //fs_log("data %d last %d total %lld\n", data, last, stat_queue->total); stat_queue->seq_no += 1; if (stat_queue->count < stat_queue->max_count) { stat_queue->count++; } }
/* #Nombre: genera_cuadruplo_while_end #Descripcion: Genera el cuadruplo que regresa al inicio del MIENTRAS y rellena el cuadruplo generado en genera_cuadruplo_if_then_while_do con el numero de cuadruplo siguiente */ void genera_cuadruplo_while_end(){ int falso = GPOINTER_TO_INT(g_queue_pop_tail(p_saltos)); int retorno = GPOINTER_TO_INT(g_queue_pop_tail(p_saltos)); insertar_cuadruplo(GOTO, -1, -1, retorno); Cuadruplo *c = (Cuadruplo*)g_ptr_array_index(cuadruplos, falso); c->cuatro = c_no; }
/* #Nombre: genera_cuadruplo_imprime #Descripcion: Genera el cuadruplo para imprimir un dato atomico */ void genera_cuadruplo_imprime(){ //Verifica que no se quiera imprimir una figura int aux = GPOINTER_TO_INT(g_queue_pop_tail(p_tipos)); if(aux == 5){ printf("Error en linea %d: La instruccion IMPRIME no sirve con figuras\n", yylineno); exit(EXIT_FAILURE); } //Obtiene el dato para imprimir y genera el cuadruplo correspondiente int operando = GPOINTER_TO_INT(g_queue_pop_tail(p_operandos)); insertar_cuadruplo(PRINT,-1,-1,operando); }
static void rtsp_client_free(RTSP_Client *client) { GString *outbuf = NULL; close(client->sd); g_free(client->local_host); g_free(client->remote_host); rtsp_session_free(client->session); if ( client->channels ) g_hash_table_destroy(client->channels); /* Remove the output queue */ if ( client->out_queue ) { while( (outbuf = g_queue_pop_tail(client->out_queue)) ) g_string_free(outbuf, TRUE); g_queue_free(client->out_queue); } if ( client->input ) /* not present on SCTP or HTTP transports */ g_byte_array_free(client->input, true); g_slice_free(RFC822_Request, client->pending_request); g_slice_free1(client->sa_len, client->peer_sa); g_slice_free1(client->sa_len, client->local_sa); g_slice_free(RTSP_Client, client); fnc_log(FNC_LOG_INFO, "[client] Client removed"); }
static gboolean qq_tray_button_press(GtkStatusIcon *tray, GdkEvent *event , gpointer data) { GdkEventButton *buttonevent = (GdkEventButton*)event; /* Only handle left clicked. */ if(buttonevent -> button != 1 || buttonevent -> type != GDK_BUTTON_PRESS){ return FALSE; } QQTrayPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE(tray, qq_tray_get_type() , QQTrayPriv); gchar *uin = g_queue_pop_tail(priv -> blinking_queue); if(uin == NULL){ /* If there is no new msg, show or hide the main window. */ qq_mainwindow_show_hide(main_win); return FALSE; } GtkWidget *cw = gqq_config_lookup_ht(cfg, "chat_window_map", uin); if(cw != NULL){ gtk_widget_show(cw); } g_free(uin); if(g_queue_is_empty(priv -> blinking_queue)){ gtk_status_icon_set_blinking(tray, FALSE); GdkPixbuf *pb = gdk_pixbuf_new_from_file(IMGDIR"/webqq_icon.png" , NULL); gtk_status_icon_set_from_pixbuf(GTK_STATUS_ICON(tray), pb); g_object_unref(pb); return FALSE; } qq_tray_blinking(QQ_TRAY(tray), g_queue_peek_tail(priv -> blinking_queue)); return FALSE; }
void empathy_chat_manager_undo_closed_chat (EmpathyChatManager *self, gint64 timestamp) { EmpathyChatManagerPriv *priv = GET_PRIV (self); ChatData *data; data = g_queue_pop_tail (priv->closed_queue); if (data == NULL) return; DEBUG ("Removing %s from closed queue and starting a chat with: %s", data->room ? "room" : "contact", data->id); if (data->room) empathy_join_muc (data->account, data->id, timestamp); else if (data->sms) empathy_sms_contact_id (data->account, data->id, timestamp, NULL, NULL); else empathy_chat_with_contact_id (data->account, data->id, timestamp, NULL, NULL); g_signal_emit (self, signals[CLOSED_CHATS_CHANGED], 0, g_queue_get_length (priv->closed_queue)); chat_data_free (data); }
gpointer ring_buffer_pop(t_ring_buffer *p_buffer) { DBG("ring_buffer_pop has been called"); gsize l_buffer_size = 0; gpointer l_newest_value = NULL; if(NULL == p_buffer) { g_warning("Trying to pop from NULL ring buffer"); return NULL; } l_buffer_size = g_queue_get_length(p_buffer->ring_queue); if(0 == l_buffer_size) { DBG("Ring Buffer is empty"); return NULL; } l_newest_value = g_queue_pop_tail(p_buffer->ring_queue); DBG("Remove newest element - currently %"G_GSIZE_FORMAT" elements stored", l_buffer_size - 1); return l_newest_value; }
void add_card_in_tux_memory(MemoryItem *card) { MemoryItem *first = NULL; g_warning("Adding card %s in tux memory ", card->data); /* check if card is already in memory */ remove_card_from_tux_memory(card); first = find_card_in_tux_memory(card); if (first){ g_warning("found %s and %s !", first->data, card->data); WINNING *win = g_malloc0(sizeof(WINNING)); win->first = card; win->second = first; winning_pairs = g_list_append( winning_pairs, win); g_warning("Now %d winning pairs in tux list! ", g_list_length(winning_pairs)); remove_card_from_tux_memory(first); } g_queue_push_head(tux_memory, card); if (g_queue_get_length (tux_memory)>tux_memory_size){ g_queue_pop_tail(tux_memory); g_warning("Now tuxmemory size = %d", g_queue_get_length (tux_memory)); } }
void fingerprint_cache_prefetch(int64_t id){ switch(destor.index_category[1]){ case INDEX_CATEGORY_PHYSICAL_LOCALITY:{ struct containerMeta * cm = retrieve_container_meta_by_id(id); if (cm) { lru_cache_insert(lru_queue, cm, NULL, NULL); } else{ WARNING("Error! The container %lld has not been written!", id); exit(1); } break; } case INDEX_CATEGORY_LOGICAL_LOCALITY:{ GQueue* segments = prefetch_segments(id, destor.index_segment_prefech); VERBOSE("Dedup phase: prefetch %d segments into %d cache", g_queue_get_length(segments), destor.index_cache_size); struct segmentRecipe* sr; while ((sr = g_queue_pop_tail(segments))) { /* From tail to head */ if (!lru_cache_hits(lru_queue, &sr->id, segment_recipe_check_id)) { lru_cache_insert(lru_queue, sr, NULL, NULL); } else { /* Already in cache */ free_segment_recipe(sr); } } g_queue_free(segments); break; } } }
static gpointer g_async_queue_pop_intern_unlocked (GAsyncQueue *queue, gboolean wait, gint64 end_time) { gpointer retval; if (!g_queue_peek_tail_link (&queue->queue) && wait) { queue->waiting_threads++; while (!g_queue_peek_tail_link (&queue->queue)) { if (end_time == -1) g_cond_wait (&queue->cond, &queue->mutex); else { if (!g_cond_wait_until (&queue->cond, &queue->mutex, end_time)) break; } } queue->waiting_threads--; } retval = g_queue_pop_tail (&queue->queue); g_assert (retval || !wait || end_time > 0); return retval; }
static gboolean isBalanced(gchar * current_re) { GQueue * stack = g_queue_new(); guint i; for(i = 0; current_re[i] != '\0'; i++) { switch(current_re[i]) { case '(': case '{': case '[': g_queue_push_tail(stack,¤t_re[i]); break; case ')': case '}': case ']': if(verifyTop(g_queue_peek_tail(stack),current_re[i])) { g_queue_pop_tail(stack); }else return FALSE; break; } } return g_queue_is_empty(stack); }
static void gfire_server_query_listen(int p_socket, gpointer p_data) { gfire_server_query *query = (gfire_server_query*)p_data; query->prpl_data = NULL; query->socket = p_socket; query->timeout = g_timeout_add_seconds(1, gfire_server_query_check_timeout, query); // Populate the current server list and query them int i = 0; for(; (i < GFSQ_MAX_QUERIES) && !g_queue_is_empty(query->servers); i++) { gfire_game_query_server *server = g_queue_pop_tail(query->servers); query->cur_servers = g_list_append(query->cur_servers, server); query->driver->query(gfire_game_server_apply_query_port(query, server->server), query->full_query, p_socket); // Timeout value GTimeVal gtv; g_get_current_time(>v); server->timeout = (gtv.tv_sec * 1000) + (gtv.tv_usec / 1000); } // Start reading on the socket query->prpl_inpa = purple_input_add(p_socket, PURPLE_INPUT_READ, gfire_server_query_read, query); }
static int fs_emu_get_netplay_input_event() { fs_mutex_lock(g_input_event_mutex); int input_event = FS_POINTER_TO_INT(g_queue_pop_tail( g_input_event_queue)); fs_mutex_unlock(g_input_event_mutex); return input_event; }
static void end_render(DiaRenderer *self) { DrsRenderer *renderer = DRS_RENDERER (self); renderer->root = g_queue_pop_tail (renderer->parents); }
int bot_gl_scrollplot2d_add_point (BotGlScrollPlot2d *self, const char *name, double x, double y) { _plot2d_t *plot = g_hash_table_lookup (self->plots, name); if (!plot) return -1; while (! g_queue_is_empty (plot->points)) { _plot2d_point_t *last_pt = (_plot2d_point_t*) g_queue_peek_tail (plot->points); if (last_pt->x > x) { g_slice_free (_plot2d_point_t, last_pt); g_queue_pop_tail (plot->points); } else break; } _plot2d_point_t *pt = g_slice_new (_plot2d_point_t); pt->x = x; pt->y = y; g_queue_push_tail (plot->points, pt); while (g_queue_get_length (plot->points) > plot->max_points) { g_slice_free (_plot2d_point_t, g_queue_pop_head (plot->points)); } return 0; }
static void draw_object(DiaRenderer *self, DiaObject *object) { /* wrap in <g></g> * We could try to be smart and count the objects we using for the object. * If it is only one the grouping is superfluous and should be removed. */ DiaSvgRenderer *renderer = DIA_SVG_RENDERER (self); SvgRenderer *svg_renderer = SVG_RENDERER (self); int n_children = 0; xmlNodePtr child, group; g_queue_push_tail (svg_renderer->parents, renderer->root); /* modifying the root pointer so everything below us gets into the new node */ renderer->root = group = xmlNewNode (renderer->svg_name_space, (const xmlChar *)"g"); object->ops->draw(object, DIA_RENDERER (renderer)); /* no easy way to count? */ child = renderer->root->children; while (child != NULL) { child = child->next; ++n_children; } renderer->root = g_queue_pop_tail (svg_renderer->parents); /* if there is only one element added to the group node unpack it again */ if (1 == n_children) { xmlAddChild (renderer->root, group->children); xmlUnlinkNode (group); /* dont free the children */ xmlFree (group); } else { xmlAddChild (renderer->root, group); } }
static void add_url_media_cb (const gchar *url, gpointer user_data) { AddMediaUrlData *amud = (AddMediaUrlData *) user_data; SearchData *sd = amud->sd; if (url) { grl_media_set_url (amud->media, url); } amud->computed = TRUE; /* Try to send in order all the processed elements */ while ((amud = g_queue_peek_tail (sd->queue)) && amud != NULL && amud->computed) { sd->ss->callback (sd->ss->source, sd->ss->operation_id, amud->media, amud->index, sd->ss->user_data, NULL); g_queue_pop_tail (sd->queue); g_slice_free (AddMediaUrlData, amud); } /* If there are still elements not processed let's wait for them */ if (amud == NULL) { g_queue_free (sd->queue); g_slice_free (SearchData, sd); } }
static gboolean gam_dnotify_pipe_handler(gpointer user_data) { char buf[5000]; DNotifyData *data; gpointer fd; int i; GAM_DEBUG(DEBUG_INFO, "gam_dnotify_pipe_handler()\n"); g_io_channel_read_chars(pipe_read_ioc, buf, sizeof(buf), NULL, NULL); i = 0; while ((fd = g_queue_pop_tail(changes)) != NULL) { G_LOCK(dnotify); data = g_hash_table_lookup(fd_hash, fd); G_UNLOCK(dnotify); if (data == NULL) continue; GAM_DEBUG(DEBUG_INFO, "handling signal\n"); gam_poll_generic_scan_directory(data->path); i++; } GAM_DEBUG(DEBUG_INFO, "gam_dnotify_pipe_handler() done\n"); return TRUE; }
static void handle_end_element (GMarkupParseContext *context, const gchar *name, gpointer user_data, GError **err) { Parser *parser = user_data; if (strcmp (name, "output") == 0) { /* If no rotation properties were set, just use MATE_RR_ROTATION_0 */ if (parser->output->rotation == 0) parser->output->rotation = MATE_RR_ROTATION_0; g_ptr_array_add (parser->outputs, parser->output); parser->output = NULL; } else if (strcmp (name, "configuration") == 0) { g_ptr_array_add (parser->outputs, NULL); parser->configuration->outputs = (MateOutputInfo **)g_ptr_array_free (parser->outputs, FALSE); parser->outputs = g_ptr_array_new (); g_ptr_array_add (parser->configurations, parser->configuration); parser->configuration = NULL; } g_free (g_queue_pop_tail (parser->stack)); }
static void _cogl_winsys_onscreen_swap_buffers_with_damage (CoglOnscreen *onscreen, const int *rectangles, int n_rectangles) { CoglOnscreenEGL *egl_onscreen = onscreen->winsys; CoglOnscreenWayland *wayland_onscreen = egl_onscreen->platform; FrameCallbackData *frame_callback_data = g_slice_new (FrameCallbackData); flush_pending_resize (onscreen); /* Before calling the winsys function, * cogl_onscreen_swap_buffers_with_damage() will have pushed the * frame info object onto the end of the pending frames. We can grab * it out of the queue now because we don't care about the order and * we will just directly queue the event corresponding to the exact * frame that Wayland reports as completed. This will steal the * reference */ frame_callback_data->frame_info = g_queue_pop_tail (&onscreen->pending_frame_infos); frame_callback_data->onscreen = onscreen; frame_callback_data->callback = wl_surface_frame (wayland_onscreen->wayland_surface); wl_callback_add_listener (frame_callback_data->callback, &frame_listener, frame_callback_data); _cogl_list_insert (&wayland_onscreen->frame_callbacks, &frame_callback_data->link); parent_vtable->onscreen_swap_buffers_with_damage (onscreen, rectangles, n_rectangles); }
/* * Idle callback that removes the first request from the queue and * handles it. If there are no more requests, the idle source is * removed. */ static gboolean gimp_dbus_service_open_idle (GimpDBusService *service) { OpenData *data; if (! service->gimp->restored) return TRUE; data = g_queue_pop_tail (service->queue); if (data) { file_open_from_command_line (service->gimp, data->file, data->as_new, NULL, /* FIXME monitor */ 0 /* FIXME monitor */); gimp_dbus_service_open_data_free (data); return TRUE; } service->source = NULL; return FALSE; }
static void remote_client_empty_queue (RemoteClient* self) { /* Empty the queue of any outstanding requests */ RemoteClosure *closure; while ((closure = g_queue_pop_tail(self->response_queue))) g_free(closure); }
/** * free all pool entries of the queue * * used as GDestroyFunc in the user-hash of the pool * * @param q a GQueue to free * * @see network_connection_pool_new * @see GDestroyFunc */ static void g_queue_free_all(gpointer q) { GQueue *queue = q; network_connection_pool_entry *entry; while ((entry = g_queue_pop_tail(queue))) network_connection_pool_entry_free(entry, TRUE); g_queue_free(queue); }
void navqueue_free() { while (! g_queue_is_empty(navigation_queue)) { g_free(g_queue_pop_tail(navigation_queue)); } g_queue_free(navigation_queue); }
gboolean rtp_watch_write_pending(RTP_watch *watch) { GstRTSPResult res; IO_rec *rec; g_mutex_lock(watch->mutex); do { if (!watch->write_buffer) { rec = g_queue_pop_tail(watch->output); if (rec == NULL) { g_mutex_unlock(watch->mutex); g_event_remove_events_sync((GEvent*)watch, EV_WRITE); return TRUE; } watch->write_buffer = rec->data; watch->write_off = 0; watch->write_size = rec->size; if (watch->backlog < rec->size) watch->backlog = rec->size; watch->backlog -= rec->size; g_slice_free(IO_rec, rec); } res = rtp_watch_write_bytes(g_event_fd(watch), watch->write_buffer, &watch->write_off, watch->write_size, &watch->err_code); g_mutex_unlock(watch->mutex); if (res != GST_RTSP_OK) { if (res == GST_RTSP_EINTR) { return TRUE; } else { return FALSE; } } g_mutex_lock(watch->mutex); g_free(watch->write_buffer); watch->write_buffer = NULL; } while (TRUE); g_mutex_unlock(watch->mutex); return TRUE; }