Beispiel #1
0
static GIFmetafile *copy_meta(mf_cgmo *cgmo, GIFmetafile *old,
			      int sx, int sy)
{
  GIFmetafile *newmeta = init_meta(cgmo, sx, sy);
  int i;

  /* Copy various stuff -- don't copy resize! */
  newmeta->lineIndex = old->lineIndex;
  newmeta->lineWidth = old->lineWidth;
  newmeta->fillIndex = old->fillIndex;
  newmeta->styleIndex = old->styleIndex;
  newmeta->fillStyleIndex = old->fillStyleIndex;
  newmeta->style = (int *)umalloc(sizeof(int) * MaxLineStyleLength);
  memcpy(newmeta->style, old->style, sizeof(int)*MaxLineStyleLength);
  newmeta->ws = old->ws;

  /* Copy the color info */
  for (i=0; i < old->numcolors; ++i){
    GIFcolor *color = &old->colors[i];
    if (old->colors[i].index == -1)
      break;
    allocate_color(newmeta, i, color->r, color->g, color->b);
  }
  /* Destroy the old metafile */
  destroy_meta(cgmo, old);
  /* Add this one */
  add_meta(cgmo, newmeta);
  return newmeta;
}
Beispiel #2
0
static GIFmetafile *create_meta(mf_cgmo *cgmo, int sx, int sy)
{
  GIFmetafile *newmeta = init_meta(cgmo, sx, sy);

  assert(newmeta->image);
  add_meta(cgmo, newmeta);
  return newmeta;
}
Beispiel #3
0
Datei: memory.c Projekt: 8l/SECD
cell_t *alloc_array(secd_t *secd, size_t size) {
    /* look through the list of arrays */
    cell_t *cur = secd->arrlist;
    while (not_nil(mcons_next(cur))) {
        if (is_array_free(secd, cur)) {
            size_t cursize = arrmeta_size(secd, cur);
            if (cursize >= size) {
                /* allocate this gap */
                if (cursize > size + 1) {
                    /* make a free gap after */
                    cell_t *newmeta = cur + size + 1;
                    cell_t *prevmeta = mcons_prev(cur);
                    init_meta(secd, newmeta, prevmeta, cur);

                    cur->as.mcons.prev = newmeta;
                    prevmeta->as.mcons.next = newmeta;

                    mark_free(newmeta, true);
                }
                mark_free(cur, false);
                return meta_mem(cur);
            }
        }
        cur = mcons_next(cur);
    }

    /* no chunks of sufficient size found, move secd->arrayptr */
    if (secd->arrayptr - secd->fixedptr <= (int)size)
        return &secd_out_of_memory;

    /* create new metadata cons at arrayptr - size - 1 */
    cell_t *oldmeta = secd->arrayptr;

    cell_t *meta = oldmeta - size - 1;
    init_meta(secd, meta, oldmeta, SECD_NIL);

    oldmeta->as.mcons.next = meta;

    secd->arrayptr = meta;

    memdebugf("NEW ARR[%ld], size %zd\n", cell_index(secd, meta), size);
    mark_free(meta, false);
    return meta_mem(meta);
}
Beispiel #4
0
void pres_c_1_init(pres_c_1 *pres)
{
	pres->mint.defs.defs_len = 0;
	pres->mint.defs.defs_val = 0;
	pres->cast = cast_new_scope(0);
	pres->stubs_cast = cast_new_scope(0);
	pres->pres_cast = cast_new_scope(0);
	pres->a.defs.defs_len = 0;
	pres->a.defs.defs_val = 0;
	init_meta(&pres->a.meta_data);
	pres->stubs.stubs_len = 0;
	pres->stubs.stubs_val = 0;
	pres->pres_context = 0;
	pres->error_mappings.error_mappings_len = 0;
	pres->error_mappings.error_mappings_val = 0;
	pres->unpresented_channels.unpresented_channels_len = 0;
	pres->unpresented_channels.unpresented_channels_val = 0;
	pres->pres_attrs = create_tag_list(0);
	init_meta(&pres->meta_data);
	pres->cast_language = CAST_C;
}
Beispiel #5
0
int			main(int ac, char **av)
{
	t_meta	*meta;

	if (ac == 2)
	{
		meta = init_meta();
		file_to_tab(open_file(av[1]), meta);
		verif_tetri(meta);
		fillit(meta);
		free_meta(meta);
	}
	else
		ft_putendl("usage: ./fillit source_file");
	return (0);
}
Beispiel #6
0
ledger_status ledger_partition_open(ledger_partition *partition, const char *topic_path,
                                    unsigned int partition_number, ledger_partition_options *options) {
    ledger_status rc;
    int fd = 0;
    int lock_fd = 0;
    char part_num[5];
    ssize_t path_len;
    char *partition_path = NULL;
    struct stat st;

    partition->path = NULL;
    partition->opened = false;
    partition->number = partition_number;

    rc = snprintf(part_num, 5, "%d", partition_number);
    ledger_check_rc(rc > 0, LEDGER_ERR_GENERAL, "Error building partition dir part");

    path_len = ledger_concat_path(topic_path, part_num, &partition_path);
    ledger_check_rc(path_len > 0, path_len, "Failed to construct partition directory path");

    memcpy(&partition->options, options, sizeof(ledger_partition_options));
    partition->path = partition_path;
    partition->path_len = path_len;

    rc = mkdir(partition_path, 0755);
    ledger_check_rc(rc == 0 || errno == EEXIST, LEDGER_ERR_MKDIR, "Failed to create partition directory");

    init_meta(&partition->meta);

    fd = open_meta(partition);
    ledger_check_rc(fd > 0, rc, "Failed to open meta file");

    rc = fstat(fd, &st);
    ledger_check_rc(rc == 0, LEDGER_ERR_IO, "Failed to stat meta file");

    if(st.st_size == 0) {
        rc = add_journal(partition, fd);
        ledger_check_rc(rc == LEDGER_OK, rc, "Failed to add initial journal");

        rc = fstat(fd, &st);
        ledger_check_rc(rc == 0, LEDGER_ERR_IO, "Failed to restat meta file");
    }

    rc = remap_meta(partition, fd, st.st_size);
    ledger_check_rc(rc == LEDGER_OK, rc, "Failed to read memory mapped meta file");

    lock_fd = open_lockfile(partition);
    ledger_check_rc(lock_fd > 0, rc, "Failed to open lockfile");

    rc = fstat(lock_fd, &st);
    ledger_check_rc(rc == 0, LEDGER_ERR_IO, "Failed to stat lockfile");

    if(st.st_size == 0) {
        rc = create_locks(partition, lock_fd);
        ledger_check_rc(rc == LEDGER_OK, rc, "Failed to create partition locks");

        rc = fstat(lock_fd, &st);
        ledger_check_rc(rc == 0, LEDGER_ERR_IO, "Failed to restat lock file");
    }

    rc = map_lockfile(partition, lock_fd, st.st_size);
    ledger_check_rc(rc == LEDGER_OK, rc, "Failed to read memory mapped lock file");

    close(fd);
    close(lock_fd);

    ledger_signal_init(&partition->message_signal);

    partition->opened = true;

    return LEDGER_OK;

error:
    if(partition_path) {
        free(partition_path);
    }
    if(fd) {
        close(fd);
    }
    if(lock_fd) {
        close(lock_fd);
    }
    return rc;
}
void BKE_mball_polygonize(EvaluationContext *eval_ctx, Scene *scene, Object *ob, ListBase *dispbase)
{
	MetaBall *mb;
	DispList *dl;
	unsigned int a;
	PROCESS process = {0};

	mb = ob->data;

	process.thresh = mb->thresh;

	if      (process.thresh < 0.001f) process.converge_res = 16;
	else if (process.thresh < 0.01f)  process.converge_res = 8;
	else if (process.thresh < 0.1f)   process.converge_res = 4;
	else                              process.converge_res = 2;

	if ((eval_ctx->mode != DAG_EVAL_RENDER) && (mb->flag == MB_UPDATE_NEVER)) return;
	if ((G.moving & (G_TRANSFORM_OBJ | G_TRANSFORM_EDIT)) && mb->flag == MB_UPDATE_FAST) return;

	if (eval_ctx->mode == DAG_EVAL_RENDER) {
		process.size = mb->rendersize;
	}
	else {
		process.size = mb->wiresize;
		if ((G.moving & (G_TRANSFORM_OBJ | G_TRANSFORM_EDIT)) && mb->flag == MB_UPDATE_HALFRES) {
			process.size *= 2.0f;
		}
	}

	process.delta = process.size * 0.001f;

	process.pgn_elements = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "Metaball memarena");

	/* initialize all mainb (MetaElems) */
	init_meta(eval_ctx, &process, scene, ob);

	if (process.totelem > 0) {
		build_bvh_spatial(&process, &process.metaball_bvh, 0, process.totelem, &process.allbb);

		/* don't polygonize metaballs with too high resolution (base mball to small)
		* note: Eps was 0.0001f but this was giving problems for blood animation for durian, using 0.00001f */
		if (ob->size[0] > 0.00001f * (process.allbb.max[0] - process.allbb.min[0]) ||
		    ob->size[1] > 0.00001f * (process.allbb.max[1] - process.allbb.min[1]) ||
		    ob->size[2] > 0.00001f * (process.allbb.max[2] - process.allbb.min[2]))
		{
			polygonize(&process);

			/* add resulting surface to displist */
			if (process.curindex) {
				dl = MEM_callocN(sizeof(DispList), "mballdisp");
				BLI_addtail(dispbase, dl);
				dl->type = DL_INDEX4;
				dl->nr = (int)process.curvertex;
				dl->parts = (int)process.curindex;

				dl->index = (int *)process.indices;

				for (a = 0; a < process.curvertex; a++) {
					normalize_v3(process.no[a]);
				}

				dl->verts = (float *)process.co;
				dl->nors = (float *)process.no;
			}
		}
	}

	freepolygonize(&process);
}