/** * Main processing routine of Sally. This function processes chunks of * strings. It might be suitable for OpenMP support in a later version. */ static void sally_process() { long read, i, j; int chunk; const char *hash_file; /* Check if a hash file is set */ config_lookup_string(&cfg, "features.hash_file", &hash_file); /* Get chunk size */ config_lookup_int(&cfg, "input.chunk_size", &chunk); /* Allocate space */ fvec_t **fvec = malloc(sizeof(fvec_t *) * chunk); string_t *strs = malloc(sizeof(string_t) * chunk); if (!fvec || !strs) fatal("Could not allocate memory for embedding"); info_msg(1, "Processing %d strings in chunks of %d.", entries, chunk); for (i = 0, read = 0; i < entries; i += read) { read = input_read(strs, chunk); if (read <= 0) fatal("Failed to read strings from input '%s'", input); /* Generic preprocessing of input */ input_preproc(strs, read); #ifdef ENABLE_OPENMP #pragma omp parallel for #endif for (j = 0; j < read; j++) { fvec[j] = fvec_extract(strs[j].str, strs[j].len); fvec_set_label(fvec[j], strs[j].label); fvec_set_source(fvec[j], strs[j].src); } if (!output_write(fvec, read)) fatal("Failed to write vectors to output '%s'", output); /* Free memory */ input_free(strs, read); output_free(fvec, read); /* Reset hash if enabled but no hash file is set */ if (fhash_enabled() && !strlen(hash_file) > 0) fhash_reset(); prog_bar(0, entries, i + read); } free(fvec); free(strs); }
static void outputs_free (MateOutputInfo **outputs) { int i; g_assert (outputs != NULL); for (i = 0; outputs[i] != NULL; ++i) output_free (outputs[i]); g_free (outputs); }
static void parser_free (Parser *parser) { int i; GList *list; g_assert (parser != NULL); if (parser->output) output_free (parser->output); if (parser->configuration) mate_rr_config_free (parser->configuration); for (i = 0; i < parser->outputs->len; ++i) { MateOutputInfo *output = parser->outputs->pdata[i]; output_free (output); } g_ptr_array_free (parser->outputs, TRUE); for (i = 0; i < parser->configurations->len; ++i) { MateRRConfig *config = parser->configurations->pdata[i]; mate_rr_config_free (config); } g_ptr_array_free (parser->configurations, TRUE); for (list = parser->stack->head; list; list = list->next) g_free (list->data); g_queue_free (parser->stack); g_free (parser); }
static void screen_info_free (ScreenInfo *info) { MateRROutput **output; MateRRCrtc **crtc; MateRRMode **mode; g_assert (info != NULL); #ifdef HAVE_RANDR if (info->resources) { XRRFreeScreenResources (info->resources); info->resources = NULL; } #endif if (info->outputs) { for (output = info->outputs; *output; ++output) output_free (*output); g_free (info->outputs); } if (info->crtcs) { for (crtc = info->crtcs; *crtc; ++crtc) crtc_free (*crtc); g_free (info->crtcs); } if (info->modes) { for (mode = info->modes; *mode; ++mode) mode_free (*mode); g_free (info->modes); } if (info->clone_modes) { /* The modes themselves were freed above */ g_free (info->clone_modes); } g_free (info); }
static void _cogl_winsys_egl_display_destroy (CoglDisplay *display) { CoglDisplayEGL *egl_display = display->winsys; CoglDisplayKMS *kms_display = egl_display->platform; CoglRenderer *renderer = display->renderer; CoglRendererEGL *egl_renderer = renderer->winsys; CoglRendererKMS *kms_renderer = egl_renderer->platform; GList *l; for (l = kms_display->outputs; l; l = l->next) output_free (kms_renderer->fd, l->data); g_list_free (kms_display->outputs); kms_display->outputs = NULL; g_slice_free (CoglDisplayKMS, egl_display->platform); }
static void output_free__( void * arg) { output_free( (output_type *) arg); }