예제 #1
0
파일: CPath.c 프로젝트: bencz/DotGnu
/* Clone this path. */
CStatus
CPath_Clone(CPath  *_this,
            CPath **clone)
{
	/* ensure we have a this pointer */
	CStatus_Require((_this != 0), CStatus_ArgumentNull);

	/* ensure we have a clone pointer pointer */
	CStatus_Require((clone != 0), CStatus_ArgumentNull);

	/* create the clone path */
	CStatus_Check(CPath_Create(clone));

	/* clone the members */
	{
		/* declarations */
		CPointF *tmpP;
		CByte   *tmpT;

		/* get the count and capacity */
		const CUInt32 count    = _this->count;
		const CUInt32 capacity = ((count + 31) & ~31);

		/* allocate the clone points list */
		if(!(tmpP = (CPointF *)CMalloc(capacity * sizeof(CPointF))))
		{
			CPath_Destroy(clone);
			return CStatus_OutOfMemory;
		}

		/* allocate the clone types list */
		if(!(tmpT = (CByte *)CMalloc(capacity * sizeof(CByte))))
		{
			CFree(tmpP);
			CPath_Destroy(clone);
			return CStatus_OutOfMemory;
		}

		/* deep copy the points into the clone */
		CMemCopy(tmpP, _this->points, (count * sizeof(CPointF)));

		/* deep copy the types into the clone */
		CMemCopy(tmpT, _this->types, (count * sizeof(CByte)));

		/* set the clone members */
		(*clone)->capacity  = capacity;
		(*clone)->count     = count;
		(*clone)->points    = tmpP;
		(*clone)->types     = tmpT;
		(*clone)->winding   = _this->winding;
		(*clone)->newFigure = _this->newFigure;
	}

	/* return successfully */
	return CStatus_OK;
}
예제 #2
0
파일: CPath.c 프로젝트: bencz/DotGnu
/* Get the points and types in this path. */
CStatus
CPath_GetPathData(CPath    *_this,
                  CPointF **points,
                  CByte   **types,
                  CUInt32  *count)
{
	/* ensure we have a this pointer */
	CStatus_Require((_this != 0), CStatus_ArgumentNull);

	/* ensure we have a point list pointer */
	CStatus_Require((points != 0), CStatus_ArgumentNull);

	/* ensure we have a type list pointer */
	CStatus_Require((types != 0), CStatus_ArgumentNull);

	/* ensure we have a count pointer */
	CStatus_Require((count != 0), CStatus_ArgumentNull);

	/* get the path data */
	{
		/* get the count and sizes */
		const CUInt32 cnt   = _this->count;
		const CUInt32 sizeP = (cnt * sizeof(CPointF));
		const CUInt32 sizeT = (cnt * sizeof(CByte));

		/* allocate the point list */
		if(!(*points = (CPointF *)CMalloc(sizeP)))
		{
			*types = 0;
			*count = 0;
			return CStatus_OutOfMemory;
		}

		/* allocate the type list */
		if(!(*types = (CByte *)CMalloc(sizeT)))
		{
			CFree(*points);
			*points = 0;
			*count = 0;
			return CStatus_OutOfMemory;
		}

		/* get the points */
		CMemCopy(*points, _this->points, sizeP);

		/* get the types */
		CMemCopy(*types, _this->types, sizeT);

		/* get the count */
		*count = cnt;
	}

	/* return successfully */
	return CStatus_OK;
}
예제 #3
0
파일: CHatchBrush.c 프로젝트: bencz/DotGnu
/* Create a hatch brush. */
CStatus
CHatchBrush_Create(CHatchBrush **_this,
                   CHatchStyle   style,
                   CColor        foreground,
                   CColor        background)
{
	/* ensure we have a this pointer pointer */
	CStatus_Require((_this != 0), CStatus_ArgumentNull);

	/* ensure we have a valid hatch style */
	CStatus_Require((CHatchStyle_IsValid(style)), CStatus_Argument);

	/* allocate the brush */
	if(!(*_this = (CHatchBrush *)CMalloc(sizeof(CHatchBrush))))
	{
		return CStatus_OutOfMemory;
	}

	/* initialize the members */
	(*_this)->style      = style;
	(*_this)->foreground = foreground;
	(*_this)->background = background;

	/* initialize the base */
	CBrush_Initialize((CBrush *)(*_this), &CHatchBrush_Class);

	/* return successfully */
	return CStatus_OK;
}
예제 #4
0
CStatus
CBitmapSurface_Create(CBitmapSurface **_this,
                      CBitmap         *image)
{
	/* ensure we have a this pointer pointer */
	CStatus_Require((_this != 0), CStatus_ArgumentNull);

	/* ensure we have an image pointer */
	CStatus_Require((image != 0), CStatus_ArgumentNull);

	/* allocate the bitmap surface */
	if(!(*_this = (CBitmapSurface *)CMalloc(sizeof(CBitmapSurface))))
	{
		return CStatus_OutOfMemory;
	}

	/* initialize the bitmap surface */
	if(!((*_this)->image = (CBitmap *)CImage_Reference((CImage *)image)))
	{
		CFree(*_this);
		*_this = 0;
		return CStatus_OutOfMemory;
	}

	/* initialize the base */
	{
		/* declarations */
		CStatus   status;
		CSurface *surface;

		/* get this as a surface */
		surface = (CSurface *)*_this;

		/* initialize the base */
		status =
			CSurface_Initialize
				(surface, &CBitmapSurface_Class, 0, 0, image->width,
				 image->height);

		/* handle base initialization failures */
		if(status != CStatus_OK)
		{
			CBitmapSurface_Finalize(surface);
			CFree(*_this);
			*_this = 0;
			return status;
		}
	}

	/* return successfully */
	return CStatus_OK;
}
예제 #5
0
ConfHandle *
GisAllocConfHandle(void)
{
	 ConfHandle *c = (ConfHandle *)(CMalloc(confCache))(sizeof(ConfHandle));

	 memset(c, 0, sizeof(ConfHandle));

#if 0
	 time(&c->iTime);
	 time(&c->rTime);
#endif
	 c->h323EvtList = listInit();

	 return c;
}
예제 #6
0
파일: CPath.c 프로젝트: bencz/DotGnu
/* Create a path. */
CStatus
CPath_Create(CPath **_this)
{
	/* ensure we have a this pointer pointer */
	CStatus_Require((_this != 0), CStatus_ArgumentNull);

	/* allocate the path */
	if(!(*_this = (CPath *)CMalloc(sizeof(CPath))))
	{
		return CStatus_OutOfMemory;
	}

	/* initialize the path */
	CPath_Initialize(*_this);

	/* return successfully */
	return CStatus_OK;
}
예제 #7
0
CallHandle *
GisAllocCallHandle(void)
{
	 CallHandle *c = (CallHandle *)(CMalloc(callCache))(sizeof(CallHandle));

	if ( c == NULL)
	{
		return NULL;
	}

	 memset(c, 0, sizeof(CallHandle));

	 setRadiusAccountingSessionId(c);

#if 0
	 time(&c->iTime);
	 time(&c->rTime);
#endif
	 c->evtList = listInit();
	 c->fcevtList = listInit();

	 return c;
}
예제 #8
0
파일: CPath.c 프로젝트: bencz/DotGnu
/* Get the types of the points in this path. */
CStatus
CPath_GetTypes(CPath    *_this,
               CByte   **types,
               CUInt32  *count)
{
	/* ensure we have a this pointer */
	CStatus_Require((_this != 0), CStatus_ArgumentNull);

	/* ensure we have a type list pointer */
	CStatus_Require((types != 0), CStatus_ArgumentNull);

	/* ensure we have a count pointer */
	CStatus_Require((count != 0), CStatus_ArgumentNull);

	/* get the types */
	{
		/* get the count and size */
		const CUInt32 cnt  = _this->count;
		const CUInt32 size = (cnt * sizeof(CByte));

		/* allocate the type list */
		if(!(*types = (CByte *)CMalloc(size)))
		{
			*count = 0;
			return CStatus_OutOfMemory;
		}

		/* get the types */
		CMemCopy(*types, _this->types, size);

		/* get the count */
		*count = cnt;
	}

	/* return successfully */
	return CStatus_OK;
}
예제 #9
0
static CStatus
CRegionCloner_Data(CRegionInterpreter  *_this,
                   CRegionNode         *node,
                   void               **data)
{
	/* assertions */
	CASSERT((_this != 0));
	CASSERT((node  != 0));
	CASSERT((data  != 0));

	/* set the data to the default */
	*data = 0;

	/* clone the data node */
	if(node->type == CRegionType_Path)
	{
		/* declarations */
		CRegionPath *rp;

		/* get the count and sizes */
		const CUInt32 count = ((CRegionPath *)node)->count;
		const CUInt32 sizeP = (count * sizeof(CPointF));
		const CUInt32 sizeT = (count * sizeof(CByte));

		/* create the path node */
		if(!(CRegionPath_Alloc(rp)))
		{
			return CStatus_OutOfMemory;
		}

		/* initialize the path node */
		rp->_base    = *node;
		rp->count    = count;
		rp->fillMode = ((CRegionPath *)node)->fillMode;

		/* allocate the point list */
		if(!(rp->points = (CPointF *)CMalloc(sizeP)))
		{
			CFree(rp);
			return CStatus_OutOfMemory;
		}

		/* allocate the type list */
		if(!(rp->types = (CByte *)CMalloc(sizeT)))
		{
			CFree(rp->points);
			CFree(rp);
			return CStatus_OutOfMemory;
		}

		/* copy the points */
		CMemCopy(rp->points, ((CRegionPath *)node)->points, sizeP);

		/* copy the types */
		CMemCopy(rp->types, ((CRegionPath *)node)->types, sizeT);

		/* set the clone */
		*data = (void *)rp;
	}
	else if(node->type == CRegionType_Rectangle)
	{
		/* declarations */
		CRegionRect *rr;

		/* create the rectangle node */
		if(!(CRegionRect_Alloc(rr)))
		{
			return CStatus_OutOfMemory;
		}

		/* initialize the rectangle node */
		rr->_base     = *node;
		rr->rectangle = ((CRegionRect *)node)->rectangle;

		/* set the clone */
		*data = (void *)rr;
	}
	else
	{
		/* declarations */
		CRegionNode *rn;

		/* create the node */
		if(!(CRegionNode_Alloc(rn)))
		{
			return CStatus_OutOfMemory;
		}

		/* initialize the node */
		*rn = *node;

		/* set the clone */
		*data = (void *)rn;
	}

	/* return successfully */
	return CStatus_OK;
}