当前位置: 首页>>代码示例>>C++>>正文


C++ pj_malloc函数代码示例

本文整理汇总了C++中pj_malloc函数的典型用法代码示例。如果您正苦于以下问题:C++ pj_malloc函数的具体用法?C++ pj_malloc怎么用?C++ pj_malloc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了pj_malloc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: convrgb_read_image

Errcode convrgb_read_image(Image_file *ifile, Rcel *screen, Anim_info *ai, int rgb_choice)
/*****************************************************************************
 *
 ****************************************************************************/
{
	Errcode err;
	Rgbctl	*ctl;

	if (NULL == (ctl = pj_zalloc(sizeof(Rgbctl))))
		return Err_no_memory;

	ctl->ifile	= ifile;
	ctl->width	= ai->width;
	ctl->height = ai->height;

	if ((err = pdr_rgb_seekstart(ifile)) < Success)
		goto OUT;
	else
		ctl->is_flipped = (err > 0) ? TRUE : FALSE;

	if (NULL == (ctl->rgb_bufs[0] = pj_malloc(ai->width)) ||
		NULL == (ctl->rgb_bufs[1] = pj_malloc(ai->width)) ||
		NULL == (ctl->rgb_bufs[2] = pj_malloc(ai->width)) ||
		NULL == (ctl->linebuf	  = pj_malloc(3*ai->width)))
		{
		err = Err_no_memory;
		goto OUT;
		}

	switch (rgb_choice)
		{
		case RGB_SCALED:
			err = rgb_read_scaled(ctl, screen);
			break;
		case RGB_COLOR:
			err = rgb_read_color(ctl, screen);
			break;
		case RGB_GREY:
			err = rgb_read_grey(ctl, screen);
			break;
		}

OUT:

	pj_gentle_free(ctl->rgb_bufs[0]);
	pj_gentle_free(ctl->rgb_bufs[1]);
	pj_gentle_free(ctl->rgb_bufs[2]);
	pj_gentle_free(ctl->linebuf);
	pj_free(ctl);

	cleanup_toptext();
	return err;
}
开发者ID:AnimatorPro,项目名称:Animator-Pro,代码行数:53,代码来源:CONVRGB.C

示例2: nad_ctable_load

int nad_ctable_load( struct CTABLE *ct, FILE *fid )

{
    int  a_size;

    fseek( fid, sizeof(struct CTABLE), SEEK_SET );

    /* read all the actual shift values */
    a_size = ct->lim.lam * ct->lim.phi;
    ct->cvs = (FLP *) pj_malloc(sizeof(FLP) * a_size);
    if( ct->cvs == NULL 
        || fread(ct->cvs, sizeof(FLP), a_size, fid) != a_size )
    {
        pj_dalloc( ct->cvs );
        ct->cvs = NULL;

        if( getenv("PROJ_DEBUG") != NULL )
        {
            fprintf( stderr, 
            "ctable loading failed on fread() - binary incompatible?\n" );
        }

        pj_errno = -38;
        return 0;
    }

    return 1;
} 
开发者ID:naadsm,项目名称:proj4_delphi,代码行数:28,代码来源:nad_init.c

示例3: unfli

Errcode unfli(Rcel *f, /* screen to update */
		 int ix,	/* which frame of file to read */
		 int wait)	/* wait for vblank (and update hardward color registers)? */

/* allocate a buffer to read in a compressed delta frame from FLX (indexed
   FLI) file.  If can't allocate buffer go swap out everything we can 
   and try again.  Once got the buffer call above routine to read in 
   frame and eventually uncompress it. */
{
struct fli_frame *frame;	/* buffer area */
Errcode err;
long size;
int pushed = 0;

	size = flix.idx[ix].fsize;
	if((frame = pj_malloc(Max(size,sizeof(Fli_frame)))) == NULL)
	{
		pushed = 1;
		push_most();
		if ((frame = begmem(size)) == NULL)
		{
			err = Err_reported;
			goto OUT;
		}
	}
	err = gb_unfli_flx_frame(&flix,f, ix, wait, frame);

OUT:
	pj_gentle_free(frame);
	if (pushed)
		pop_most();
	return(err);
}
开发者ID:AnimatorPro,项目名称:Animator-Pro,代码行数:33,代码来源:fli.c

示例4: get_abs_ctable

static Errcode get_abs_ctable(Sep_cb *sep)
{
UBYTE *s;
Rgb3 *d;
int i;

if (vs.sep_rgb == 1)
	{
	/* copy the absolute rgb values of cnums somewhere */
	get_color_rgb(vs.ccolor,vb.pencel->cmap,&sep->sep_rgb_dest);

	if ((sep->abs_ctable = pj_malloc(sep->p.ccount*3)) == NULL)
		return(Err_no_memory);

	s = sep->p.ctable;
	d = sep->abs_ctable;
	i = sep->p.ccount;
	while (--i >= 0)
		{
		get_color_rgb(*s++,vb.pencel->cmap,d);
		++d;
		}
	}
return(Success);
}
开发者ID:AnimatorPro,项目名称:Animator-Pro,代码行数:25,代码来源:SEP.C

示例5: reload_tsettings

Errcode reload_tsettings(Vsettings *pvs,Vset_flidef *fdef)
/* called whenever a tempflx is opened to reload ram settings state */
{
Errcode err;
Tsettings_file *buf;

	if((buf = pj_malloc(sizeof(*buf))) == NULL)
		return(Err_no_memory);
	if((err = read_gulp(tsettings_name, buf, (long)sizeof(*buf))) < Success)
		goto error;

	if (buf->vs.zoomscale == 0) {
		err = Err_corrupted;
		goto error;
	}

	if(pvs)
		*pvs = buf->vs;
	if(fdef)
		*fdef = buf->fdef;

	load_ink_strengths(buf->vslow.inkstrengths);

error:
	pj_freez(&buf);
	return(err);
}
开发者ID:AnimatorPro,项目名称:Animator-Pro,代码行数:27,代码来源:vsetting.c

示例6: pj_malloc

struct CTABLE *nad_ctable_init( FILE * fid )
{
    struct CTABLE *ct;
    int		id_end;

    /* read the table header */
    ct = (struct CTABLE *) pj_malloc(sizeof(struct CTABLE));
    if( ct == NULL 
        || fread( ct, sizeof(struct CTABLE), 1, fid ) != 1 )
    {
        pj_errno = -38;
        return NULL;
    }

    /* do some minimal validation to ensure the structure isn't corrupt */
    if( ct->lim.lam < 1 || ct->lim.lam > 100000 
        || ct->lim.phi < 1 || ct->lim.phi > 100000 )
    {
        pj_errno = -38;
        return NULL;
    }
    
    /* trim white space and newlines off id */
    for( id_end = strlen(ct->id)-1; id_end > 0; id_end-- )
    {
        if( ct->id[id_end] == '\n' || ct->id[id_end] == ' ' )
            ct->id[id_end] = '\0';
        else
            break;
    }

    ct->cvs = NULL;

    return ct;
}
开发者ID:dyang02,项目名称:SurrogateTools,代码行数:35,代码来源:nad_init.c

示例7: nad_ctable2_load

int nad_ctable2_load( projCtx ctx, struct CTABLE *ct, FILE *fid )

{
    int  a_size;

    fseek( fid, 160, SEEK_SET );

    /* read all the actual shift values */
    a_size = ct->lim.lam * ct->lim.phi;
    ct->cvs = (FLP *) pj_malloc(sizeof(FLP) * a_size);
    if( ct->cvs == NULL 
        || fread(ct->cvs, sizeof(FLP), a_size, fid) != a_size )
    {
        pj_dalloc( ct->cvs );
        ct->cvs = NULL;

        if( getenv("PROJ_DEBUG") != NULL )
        {
            fprintf( stderr,
            "ctable2 loading failed on fread() - binary incompatible?\n" );
        }

        pj_ctx_set_errno( ctx, -38 );
        return 0;
    }

    if( !IS_LSB )
    {
        swap_words( ct->cvs, 4, a_size * 2 );
    }

    return 1;
} 
开发者ID:aleaf,项目名称:swb,代码行数:33,代码来源:nad_init.c

示例8: get_cut

static Errcode get_cut(Pixel offc, Pixel onhi, Pixel onlo)

/* returns Err_abort if right click or key hit returns ZOOM_WNDOID if in zoom 
 * window FLI_WNDOID if in fli window leaves values in icb as of last click 
 * and iostate set to window click was in */
{
Wiostate ios;
Cutdata cd;
int ret;

	if(NULL == (cd.hline = pj_malloc(vb.pencel->width + vb.pencel->height)))
		return(Err_no_memory);

	save_wiostate(&ios);
	cd.vline = cd.hline + vb.pencel->width;
	cd.wndoid = -1;
	cd.doneonce = 0;
	cd.oncol = onhi;
	cd.offcol = offc;
	vinit_marqihdr(&cd.mh,1,1);

	ret = anim_wait_input(KEYHIT|MBRIGHT|MBPEN,KEYHIT|MBRIGHT|MBPEN|MMOVE,
						  cd.mh.waitcount,anim_cut,&cd);

	cleanup_toptext();
	restore_cut(&cd);
	pj_free(cd.hline);
	if(ret < 0)
		rest_wiostate(&ios);
	else 
		show_mouse();
	return(ret);
}
开发者ID:AnimatorPro,项目名称:Animator-Pro,代码行数:33,代码来源:CUTCURS.C

示例9: svga_open_graphics

static Errcode svga_open_graphics(Vdevice *dev, SVGARast *r,
		LONG width, LONG height, USHORT mode)
/*****************************************************************************
 * open the driver in the requested mode.
 ****************************************************************************/
{
	Errcode err;
	SMInfo	*sminf;

	if (mode >= smodecount) 			// If init/detect failed or caller
		return Err_no_such_mode;		// asked for bad mode, this catches it.

	sminf = &pj_vdrv_modeinfo[mode];

	if (width  != sminf->width ||		// Docs say to do this; I wanna
		height != sminf->height)		// know how it could ever happen
		return Err_wrong_res;			// short of a totally buggy host!

	if (height > 1536)					// ytable size in drvcomn.asm is
		return Err_too_big; 			// hardcodes to this many entries.

	if (width+width+4 > LCLBUF_SIZE)	// blit code assumes it can fit 2 full
		return Err_too_big; 			// lines plus a dword in local buffer.

	if (NULL == (pj_vdrv_wcontrol.localbuf = pj_malloc(LCLBUF_SIZE))) // get blit buffer
		return Err_no_memory;

	r->lib	  = get_rlib(); 						// fill in details in
	r->type   = mode + dev->first_rtype;			// the caller's Raster
	r->width  = width;								// structure.  do it before
	r->height = height; 							// calling setmode() in
	r->pdepth = 8;									// case setmode wants to
	r->grclib = dev->grclib;						// change an rlib vector.

	if (Success > (err = pj_svga_setmode(sminf)))	// fire up requested mode,
		goto ERROR_EXIT;							// punt if error, else
	else											// save longword return val
		old_mode_data = err & 0xFFFFFF7F;			// for passing to clrmode().

	/*
	 * bogus aspect ratio calcs...these are wrong, but at least they don't
	 * break the PJ circle tool...
	 */

	if (r->height < 480) {
		r->aspect_dx = 6;
		r->aspect_dy = 5;
	} else {
		r->aspect_dx = 1;
		r->aspect_dy = 1;
	}

	device_is_open = TRUE;
	return Success;

ERROR_EXIT:

	svga_close_graphics(dev);
	return err;
}
开发者ID:AnimatorPro,项目名称:Animator-Pro,代码行数:60,代码来源:SVGAVDEV.C

示例10: flow_save_frames

static Errcode flow_save_frames(Image_file *ifile,
								Rcel *screen,
								ULONG num_frames,
								Errcode (*seek_frame)(int ix,void *seek_data),
								void *seek_data,
								Rcel *work_screen )
{
Errcode err = Success;
ULONG i;
Fli_frame *cbuf;
Flifile *flif = ((Flifile *)ifile);

	if(screen->width != 320 || screen->height != 200)
		return(Err_wrong_res);

	cbuf = NULL;
	for(i = 0;;++i)
	{
		if(NULL == (cbuf = pj_malloc(CBUF_SIZE)))
		{
			err = Err_no_memory;
			break;
		}
		if(i == 0)
		{
			if((err = flow_add_frame1(flif, cbuf, screen)) < Success)
				break;

			/* if only one frame terminate file and exit */

			if(num_frames <= 1)
			{
				err = flow_i_add_empty_ring(flif);
				break;
			}
		}
		else if(i < num_frames)
		{
			if((err = seek_frame(i,seek_data)) < Success)
				break;
			if((err = flow_add_next(flif,cbuf,work_screen,screen)) < Success)
				break;
		}
		else
		{
			/* if larger than one frame file re-seek to first frame */
			if((err = seek_frame(0,seek_data)) < Success)
				break;
			err = flow_add_ring(flif,cbuf,work_screen,screen);
			break; /* we are done ! */
		}
		pj_freez(&cbuf);
		pj_blitrect(screen,0,0,work_screen,0,0,320,200);
		pj_cmap_copy(screen->cmap, work_screen->cmap);
	}

	pj_freez(&cbuf);
	return(err);
}
开发者ID:AnimatorPro,项目名称:Animator-Pro,代码行数:59,代码来源:flilo.c

示例11:

char *clone_string(char *s)
{
char *d;

if ((d = (char *)pj_malloc(strlen(s)+1)) != NULL)
	strcpy(d, s);
return(d);
}
开发者ID:AnimatorPro,项目名称:Animator-Pro,代码行数:8,代码来源:STRCLONE.C

示例12:

void *pj_zalloc(long size)
/* same as laskmem bu returns it cleared "c" */
{
void *mem;

	if(NULL != (mem = pj_malloc(size)))
		zero_structure(mem,size);
	return(mem);
}
开发者ID:AnimatorPro,项目名称:Animator-Pro,代码行数:9,代码来源:MEMASK.C

示例13: makeT

	static Tseries * /* create power series structure */
makeT(int nru, int nrv) {
	Tseries *Ts;
	int i;

	if ((Ts = (Tseries *)pj_malloc(sizeof(Tseries))) &&
		(Ts->cu = (struct PW_COEF *)pj_malloc(
			sizeof(struct PW_COEF) * nru)) &&
		(Ts->cv = (struct PW_COEF *)pj_malloc(
			sizeof(struct PW_COEF) * nrv))) {
		for (i = 0; i < nru; ++i)
			Ts->cu[i].c = 0;
		for (i = 0; i < nrv; ++i)
			Ts->cv[i].c = 0;
		return Ts;
	} else
		return 0;
}
开发者ID:daj,项目名称:iOS-OfflineMaps-Example,代码行数:18,代码来源:mk_cheby.c

示例14:

void *pj_zalloc(unsigned size)
/****************************************************************************
 *
 ***************************************************************************/
{
void *pt;
if ((pt = pj_malloc(size)) == NULL)
	return(NULL);
poco_zero_bytes(pt,(size_t)size);
return(pt);
}
开发者ID:AnimatorPro,项目名称:Animator-Pro,代码行数:11,代码来源:MAIN.C

示例15: rgb_scale_x

static Errcode rgb_scale_x(Rgbctl *ctl, Rcel *screen)
/*****************************************************************************
 * Read rgb file, break it into RGB components, scale the components
 * in the X dimension, and write them out to our RGB files.
 ****************************************************************************/
{
	Errcode err = Success;
	int 	height = ctl->height;
	int 	width  = ctl->width;
	int 	dwidth = screen->width;
	UBYTE	*scale_buf = NULL;
	Cmap	*cmap = screen->cmap;
	int 	j;
	int 	i;
	int 	sofar = 0;

	soft_status_line("ctop_xscale");
	if (NULL == (scale_buf = pj_malloc(dwidth)))
		{
		err = Err_no_memory;
		goto OUT;
		}

	if (Success > (err = open_rgb_files("wb",3)))
		goto OUT;

	if (Success > (err = pdr_rgb_seekstart(ctl->ifile)))
		goto OUT;

	for (i=0; i<height; ++i)
		{
		if (--sofar <= 0)
			{
			if ((err = soft_abort("rgb_abort")) < Success)
				goto OUT;
			soft_status_line("!%d%d", "ctop_scaleline", i, height);
			sofar = 25;
			}
		if ((err = pdr_rgb_readline(ctl->ifile, ctl->linebuf)) < Success)
			goto OUT;
		rgb3_to_buffers(ctl->linebuf, ctl->rgb_bufs, width);
		j = 3;
		while (--j >= 0)
			{
			pix_ave_scale(ctl->rgb_bufs[j], width, scale_buf, dwidth);
			if ((err = ffwrite(rgb_files[j], scale_buf, dwidth)) < Success)
				goto OUT;
			}
		}
OUT:
	pj_gentle_free(scale_buf);
	close_rgb_files();
	return err;
}
开发者ID:AnimatorPro,项目名称:Animator-Pro,代码行数:54,代码来源:CONVRGB.C


注:本文中的pj_malloc函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。