Ejemplo n.º 1
0
void ifft_free(ifft_susp_type susp)
{
    if (susp->samples) free(susp->samples);
    if (susp->table) table_unref(susp->table);
    if (susp->outbuf) free(susp->outbuf);
    ffree_generic(susp, sizeof(ifft_susp_node), "ifft_free");
}
Ejemplo n.º 2
0
static void
table_item_destroy (struct output_item *output_item)
{
  struct table_item *item = to_table_item (output_item);
  free (item->title);
  free (item->caption);
  table_unref (item->table);
  free (item);
}
Ejemplo n.º 3
0
/* Decreases PAGE's reference count and destroys PAGE if this causes the
   reference count to fall to zero. */
void
render_page_unref (struct render_page *page)
{
  if (page != NULL && --page->ref_cnt == 0)
    {
      int i;
      struct render_overflow *overflow, *next;

      HMAP_FOR_EACH_SAFE (overflow, next, struct render_overflow, node,
                          &page->overflows)
        free (overflow);
      hmap_destroy (&page->overflows);

      table_unref (page->table);
      
      for (i = 0; i < TABLE_N_AXES; ++i)
	{
	  free (page->join_crossing[i]);
	  free (page->cp[i]);
	}

      free (page);
    }
Ejemplo n.º 4
0
sound_type snd_make_convolve(sound_type x_snd, sound_type h_snd)
{
    register convolve_susp_type susp;
    rate_type sr = x_snd->sr;
    time_type t0 = x_snd->t0;
    sample_type scale_factor = 1.0F;
    time_type t0_min = t0;
    table_type table;
    double log_len;
    falloc_generic(susp, convolve_susp_node, "snd_make_convolve");
    table = sound_to_table(h_snd);
    susp->h_len = table->length;
    log_len = log(table->length) / M_LN2; /* compute log-base-2(length) */
    susp->M = (int) log_len;
    if (susp->M != log_len) susp->M++; /* round up */
    susp->N = 1 << susp->M; /* size of data blocks */
    susp->M++; /* M = log2(2 * N) */
    susp->H = (sample_type *) calloc(2 * susp->N, sizeof(susp->H[0]));
    if (!susp->H) {
        xlabort("memory allocation failure in convolve");
    }
    memcpy(susp->H, table->samples, sizeof(susp->H[0]) * susp->N);
    table_unref(table); /* don't need table now */
    /* remaining N samples are already zero-filled */
    if (fftInit(susp->M)) {
        free(susp->H);
        xlabort("fft initialization error in convolve");
    }
    rffts(susp->H, susp->M, 1);
    susp->X = (sample_type *) calloc(2 * susp->N, sizeof(susp->X[0]));
    susp->R = (sample_type *) calloc(2 * susp->N, sizeof(susp->R[0]));
    if (!susp->X || !susp->R) {
        free(susp->H);
        if (susp->X) free(susp->X);
        if (susp->R) free(susp->R);
        xlabort("memory allocation failed in convolve");
    }
    susp->R_current = susp->R + susp->N;
    susp->susp.fetch = &convolve_s_fetch;
    susp->terminate_cnt = UNKNOWN;
    /* handle unequal start times, if any */
    if (t0 < x_snd->t0) sound_prepend_zeros(x_snd, t0);
    /* minimum start time over all inputs: */
    t0_min = min(x_snd->t0, t0);
    /* how many samples to toss before t0: */
    susp->susp.toss_cnt = (long) ((t0 - t0_min) * sr + 0.5);
    if (susp->susp.toss_cnt > 0) {
        susp->susp.keep_fetch = susp->susp.fetch;
        susp->susp.fetch = convolve_toss_fetch;
    }

    /* initialize susp state */
    susp->susp.free = convolve_free;
    susp->susp.sr = sr;
    susp->susp.t0 = t0;
    susp->susp.mark = convolve_mark;
    susp->susp.print_tree = convolve_print_tree;
    susp->susp.name = "convolve";
    susp->logically_stopped = false;
    susp->susp.log_stop_cnt = logical_stop_cnt_cvt(x_snd);
    susp->susp.current = 0;
    susp->x_snd = x_snd;
    susp->x_snd_cnt = 0;
    return sound_create((snd_susp_type)susp, t0, sr, scale_factor);
}
Ejemplo n.º 5
0
Archivo: table.c Proyecto: mity/mctrl
void MCTRL_API
mcTable_Release(MC_HTABLE hTable)
{
    if(hTable)
        table_unref((table_t*) hTable);
}
Ejemplo n.º 6
0
Archivo: grid.c Proyecto: UIKit0/mctrl
static int
grid_set_table(grid_t* grid, table_t* table)
{
    if(table != NULL && table == grid->table)
        return 0;

    if(MC_ERR(table != NULL  &&  (grid->style & MC_GS_OWNERDATA))) {
        MC_TRACE("grid_set_table: Cannot install table while having style "
                 "MC_GS_OWNERDATA");
        SetLastError(ERROR_INVALID_STATE);
        return -1;
    }

    if(table != NULL) {
        table_ref(table);
    } else if(!(grid->style & (MC_GS_NOTABLECREATE | MC_GS_OWNERDATA))) {
        table = table_create(0, 0);
        if(MC_ERR(table == NULL)) {
            MC_TRACE("grid_set_table: table_create() failed.");
            return -1;
        }
    }

    if(table != NULL) {
        if(MC_ERR(table_install_view(table, grid, grid_refresh)) != 0) {
            MC_TRACE("grid_set_table: table_install_view() failed.");
            table_unref(table);
            return -1;
        }
    }

    if(grid->table != NULL) {
        table_uninstall_view(grid->table, grid);
        table_unref(grid->table);
    }

    grid->table = table;

    if(table != NULL) {
        grid->col_count = table->col_count;
        grid->row_count = table->row_count;
    } else {
        grid->col_count = 0;
        grid->row_count = 0;
    }

    grid->cache_hint[0] = 0;
    grid->cache_hint[1] = 0;
    grid->cache_hint[2] = 0;
    grid->cache_hint[3] = 0;

    if(grid->col_widths != NULL) {
        free(grid->col_widths);
        grid->col_widths = NULL;
    }

    if(grid->row_heights != NULL) {
        free(grid->row_heights);
        grid->row_heights = NULL;
    }

    if(!grid->no_redraw) {
        InvalidateRect(grid->win, NULL, TRUE);
        grid_setup_scrollbars(grid, TRUE);
    }
    return 0;
}