예제 #1
0
/* Free the saved gstate when freeing a Pattern instance. */
void
rc_free_pattern_instance(gs_memory_t * mem, void *pinst_void,
			 client_name_t cname)
{
    gs_pattern_instance_t *pinst = pinst_void;

    gs_state_free(pinst->saved);
    rc_free_struct_only(mem, pinst_void, cname);
}
예제 #2
0
파일: pxtop.c 프로젝트: ststeiger/ghostsvg
/* Do per-instance interpreter allocation/init. No device is set yet */
static int   /* ret 0 ok, else -ve error code */
pxl_impl_allocate_interp_instance(
  pl_interp_instance_t   **instance,     /* RETURNS instance struct */
  pl_interp_t            *interp,        /* dummy interpreter */
  gs_memory_t            *mem            /* allocator to allocate instance from */
)
{
	/* Allocate everything up front */
	pxl_interp_instance_t *pxli  /****** SHOULD HAVE A STRUCT DESCRIPTOR ******/
	 = (pxl_interp_instance_t *)gs_alloc_bytes( mem,
	                                            sizeof(pxl_interp_instance_t),
	                                            "pxl_allocate_interp_instance(pxl_interp_instance_t)"
                                              );
	gs_state *pgs = gs_state_alloc(mem);
	px_parser_state_t *st = px_process_alloc(mem);	/* parser init, cheap */
	px_state_t *pxs = px_state_alloc(mem);	/* inits interp state, potentially expensive */
	/* If allocation error, deallocate & return */
	if (!pxli || !pgs || !st || !pxs) {
	  if (pxli)
	    gs_free_object(mem, pxli, "pxl_impl_allocate_interp_instance(pxl_interp_instance_t)");
	  if (pgs)
	    gs_state_free(pgs);
	  if (st)
	    px_process_release(st);
	  if (pxs)
	    px_state_release(pxs);
	  return gs_error_VMerror;
	}
        gsicc_init_iccmanager(pgs);

	/* Setup pointers to allocated mem within instance */
	pxli->memory = mem;
	pxli->pgs = pgs;
	pxli->pxs = pxs;
	pxli->st = st;

	/* zero-init pre/post page actions for now */
	pxli->pre_page_action = 0;
	pxli->post_page_action = 0;

	/* General init of pxl_state */
	px_state_init(pxs, pgs);	/*pgs only needed to set pxs as pgs' client */
	pxs->client_data = pxli;
	pxs->end_page = pxl_end_page_top;	/* after px_state_init */

	/* Return success */
	*instance = (pl_interp_instance_t *)pxli;
	return 0;
}
예제 #3
0
파일: pxtop.c 프로젝트: ststeiger/ghostsvg
/* Deallocate a interpreter instance */
static int   /* ret 0 ok, else -ve error code */
pxl_impl_deallocate_interp_instance(
  pl_interp_instance_t   *instance     /* instance to dealloc */
)
{
	pxl_interp_instance_t *pxli = (pxl_interp_instance_t *)instance;
	gs_memory_t *mem = pxli->memory;
	
	px_dict_release(&pxli->pxs->font_dict);
	px_dict_release(&pxli->pxs->builtin_font_dict);
	/* do total dnit of interp state */
	px_state_finit(pxli->pxs);
	/* free halftone cache */
	gs_state_free(pxli->pgs);
	px_process_release(pxli->st);
	px_state_release(pxli->pxs);
	gs_free_object(mem, pxli, "pxl_impl_deallocate_interp_instance(pxl_interp_instance_t)");
	return 0;
}