Ejemplo n.º 1
0
Archivo: data.c Proyecto: amba/pdfout
void
pdfout_data_drop (fz_context *ctx, pdfout_data *data)
{
  switch (data->type)
    {
    case SCALAR: drop_scalar (ctx, to_scalar (ctx, data)); break;
    case ARRAY: drop_array (ctx, to_array (ctx, data)); break;
    case HASH:  drop_hash (ctx, to_hash (ctx, data)); break;
    default:
      abort ();
    }
}
Ejemplo n.º 2
0
Archivo: memory.c Proyecto: 8l/SECD
/* Deallocation */
cell_t *drop_dependencies(secd_t *secd, cell_t *c) {
    enum cell_type t = cell_type(c);
    switch (t) {
      case CELL_SYM:
        if (c->as.sym.size != DONT_FREE_THIS)
            free((char *)c->as.sym.data);
            /* TODO: this silently ignores symbol memory corruption */
            c->as.sym.size = DONT_FREE_THIS;
        break;
      case CELL_FRAME:
        drop_cell(secd, c->as.frame.io);
        // fall through
      case CELL_CONS:
        if (not_nil(c)) {
            drop_cell(secd, get_car(c));
            drop_cell(secd, get_cdr(c));
        }
        break;
      case CELL_STR:
      case CELL_ARRAY:
        drop_array(secd, arr_mem(c));
        break;
      case CELL_REF:
        drop_cell(secd, c->as.ref);
        break;
      case CELL_PORT:
        secd_pclose(secd, c);
        break;
      case CELL_ARRMETA:
        if (c->as.mcons.cells) {
            size_t size = arrmeta_size(secd, c);
            size_t i;

            /* free the items */
            for (i = 0; i < size; ++i) {
                /* don't free uninitialized */
                cell_t *ith = meta_mem(c) + i;
                if (cell_type(ith) != CELL_UNDEF)
                    drop_dependencies(secd, ith);
            }
        }
        break;
      case CELL_INT: case CELL_FUNC: case CELL_OP:
      case CELL_ERROR: case CELL_UNDEF:
        return c;
      default:
        return new_error(secd, "drop_dependencies: unknown cell_type 0x%x", t);
    }
    return c;
}