Exemple #1
0
static void
CPath_Finalize(CPath *_this)
{
	/* assertions */
	CASSERT((_this != 0));

	/* finalize the path */
	{
		/* get the point list */
		CPointF *points = _this->points;

		/* get the type list */
		CByte *types = _this->types;

		/* finalize, as needed */
		if(points != 0)
		{
			/* reset the members */
			_this->capacity  = 0;
			_this->count     = 0;
			_this->points    = 0;
			_this->types     = 0;
			_this->winding   = 0;
			_this->newFigure = 1;
			_this->hasCurves = 0;

			/* free the point list */
			CFree(points);

			/* free the type list */
			CFree(types);
		}
	}
}
Exemple #2
0
static void
CRegionCloner_FreeData(void *data)
{
	/* assertions */
	CASSERT((data != 0));

	/* free the node members, as needed */
	if(CRegionNode_IsOp(((CRegionNode *)data)))
	{
		/* get the operation node */
		CRegionOp *op = ((CRegionOp *)data);

		/* free the left operand node, as needed */
		if(op->left) { CRegionCloner_FreeData(op->left); }

		/* free the right operand node, as needed */
		if(op->right) { CRegionCloner_FreeData(op->right); }
	}
	else if(((CRegionNode *)data)->type == CRegionType_Path)
	{
		/* get the path node */
		CRegionPath *rp = ((CRegionPath *)data);

		/* free the point list */
		CFree(rp->points);

		/* free the type list */
		CFree(rp->types);
	}

	/* free the node */
	CFree(data);
}
Exemple #3
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;
}
Exemple #4
0
int mbbs_memalloc(MemType **buf, unsigned int *bufsz, unsigned int nobj, size_t objsz) {
	if (buf == (MemType **)0)
		return MEM_BADARG;
	if (bufsz == (unsigned int *)0)
		return MEM_BADARG;

	/* sufficient memory already allocated? */
	if (*bufsz >= nobj) {
		if ((*buf != (MemType *)0) && (nobj != 0) && (objsz != 0))
			MemZero(*buf, nobj * objsz);
		return MEM_SUCCESS;
	}

	if ((mem_maxallocsz != 0) && (mem_maxallocsz < (unsigned long)(nobj * objsz)))
		return MEM_OOB;

	/* free any existing memory */
	if (*buf != (MemType *)0)
		CFree((MemType *)*buf);
	*bufsz = 0;

	/* allocate new memory */
	if ((*buf = (MemType *)calloc((MemSizeType)nobj, (MemSizeType)objsz)) == (MemType *)0)
		return MEM_CALLOC;
	*bufsz = nobj;

	return MEM_SUCCESS;
}
Exemple #5
0
int
mbbs_appendstr(char **field, char *str)
/*
   User-callable routine.
   Append a string to the specified string field.
   Returns BS_SUCCESS, BS_BADARG or BS_MEMALLOC.
*/
{
    StrSizeType len;
    char *newfield;

    if (field == (char **) 0)
        return BS_BADARG;
    if ((str == (char *) 0) || (strlen(str) == 0))
        return BS_SUCCESS;

    if (*field != (char *) 0)
        len= strlen(*field);
    else
        len= (StrSizeType) 0;
    len+= strlen(str)+1;

    if ((newfield= (char *) calloc((MemSizeType) len, sizeof(char))) == (char *) 0)
        return BS_MEMALLOC;
    if (*field != (char *) 0)
        (void) strcpy(newfield, *field);
    (void) strcat(newfield, str);
    if (*field != (char *) 0)
        CFree((MemType *) *field);
    *field= newfield;

    return BS_SUCCESS;
}
Exemple #6
0
/* Destroy this brush. */
CStatus
CBrush_Destroy(CBrush **_this)
{
	/* ensure we have a this pointer pointer */
	CStatus_Require((_this != 0), CStatus_ArgumentNull);

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

	/* finalize the brush */
	(*_this)->_class->Finalize(*_this);

	/* destroy the pattern, as needed */
	if((*_this)->pattern.image != 0)
	{
		pixman_image_destroy((*_this)->pattern.image);
		(*_this)->pattern.image = 0;
	}

	/* dispose of the brush */
	CFree(*_this);

	/* null the this pointer */
	*_this = 0;

	/* return successfully */
	return CStatus_OK;
}
Exemple #7
0
void
GisFreeConfHandle(void *ptr)
{
	ConfHandle *confHandle = (ConfHandle *)ptr;

	if (confHandle->h323EvtList)
	{
		FreeH323EvtQueue(&(confHandle->h323EvtList));
	}
		
	if (confHandle->sipEvt)
	{
		SipFreeAppCallHandle(confHandle->sipEvt->data);
		free(confHandle->sipEvt);
	}

	GisFreeSetupQ931NodeId(confHandle);

	GisFreeEgressTokenNodeId(confHandle);

	if (confHandle->mediaRouted)
		nlm_freeMRvport();  // free the media routing license for this call

	(CFree(confCache))(ptr);
}
Exemple #8
0
int
mbbs_freebsfmem(BSFile *bsf)
{
	if (bsf == (BSFile *) 0)
		return BS_BADARG;

	if (bsf->bsf_srcfilenm != (char *) 0) {
		CFree((MemType *) bsf->bsf_srcfilenm);
		bsf->bsf_srcfilenm= (char *) 0;
	}
	if (bsf->bsf_log != (char *) 0) {
		CFree((MemType *) bsf->bsf_log);
		bsf->bsf_log= (char *) 0;
	}

	return BS_SUCCESS;
}
Exemple #9
0
/* 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;
}
Exemple #10
0
/* 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;
}
Exemple #11
0
int
mbbs_replacestr(char **field, char *str)
/*
   User-callable routine.
   Copy a string to the specified string field.
   Returns BS_SUCCESS, BS_BADARG or BS_MEMALLOC.
*/
{
    StrSizeType olen, nlen;
    char *newfield;

    if (field == (char **) 0)
        return BS_BADARG;
    if ((str == (char *) 0) || (strlen(str) == 0)) {
        if (*field != (char *) 0) {
            CFree((MemType *) *field);
            *field= (char *) 0;
        }
        return BS_SUCCESS;
    }

    if (*field != (char *) 0)
        olen= strlen(*field)+1;
    else
        olen= 0;
    nlen= strlen(str)+1;

    if (nlen != olen) {
        if ((newfield= (char *) calloc((MemSizeType) nlen, sizeof(char))) == (char *) 0)
            return BS_MEMALLOC;
        (void) strcpy(newfield, str);
        if (*field != (char *) 0)
            CFree((MemType *) *field);
        *field= newfield;
    }
    else
        (void) strcpy(*field, str);

    return BS_SUCCESS;
}
Exemple #12
0
int Free(void * pointer)
{
	struct alloc_head * mem_head=(struct alloc_head *)(pointer-sizeof(POINTER_LIST));
	switch(mem_head->type)
	{
		case ALLOC_TEMP:
			return TFree(pointer);
		case ALLOC_STATIC:
			return SFree(pointer);
		case ALLOC_DYNAMIC:
			return DFree(pointer);
		case ALLOC_CACHE:
			return CFree(pointer,mem_head->flag);
		default:
			return -EINVAL;
	}	
}
Exemple #13
0
/* Destroy a path. */
CStatus
CPath_Destroy(CPath **_this)
{
	/* ensure we have a this pointer pointer */
	CStatus_Require((_this != 0), CStatus_ArgumentNull);

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

	/* finalize the path */
	CPath_Finalize(*_this);

	/* free the path */
	CFree(*_this);

	/* null the this pointer */
	*_this = 0;

	/* return successfully */
	return CStatus_OK;
}
Exemple #14
0
/* Flatten curves in this path into sequences of connected line segments. */
CStatus
CPath_Flatten(CPath   *_this,
              CMatrix *matrix,
              CFloat   flatness)
{
	/* ensure we have a this pointer */
	CStatus_Require((_this != 0), CStatus_ArgumentNull);

	/* bail out now if there's nothing to flatten */
	CStatus_Require((_this->count == 0), CStatus_OK);

	/* transform the path, as needed */
	if(matrix != 0)
	{
		/* transform the points */
		CStatus_Check
			(CMatrix_TransformPoints
				(matrix, _this->points, _this->count));
	}

	/* bail out now if there's nothing more to do */
	CStatus_Require((_this->hasCurves != 0), CStatus_OK);

	/* flatten the path */
	{
		/* declarations */
		CFlattener  flattener;
		CPointF    *points;
		CByte      *types;
		CUInt32     count;
		CUInt32     capacity;
		CStatus     status;

		/* initialize the flattener */
		CFlattener_Initialize(&flattener);

		/* flatten the path */
		status =
			CFlattener_Flatten
				(&flattener, _this->points, _this->types, _this->count,
				 flatness);

		/* handle flattening failures */
		if(status != CStatus_OK)
		{
			/* finalize the flattener */
			CFlattener_Finalize(&flattener, 0, 0, 0, 0);

			/* return status */
			return status;
		}

		/* finalize the flattener */
		CFlattener_Finalize(&flattener, &points, &types, &count, &capacity);

		/* finalize the current path members */
		CFree(_this->points);
		CFree(_this->types);

		/* initialize the members */
		_this->points   = points;
		_this->types    = types;
		_this->count    = count;
		_this->capacity = capacity;
	}

	/* return successfully */
	return CStatus_OK;
}
Exemple #15
0
int
mbbs_appendlog(BSFile *bsf, char **argv)
/*
   User-callable routine.
   Appends the specified argument list to the file log
   with (i) a leading newline (if the current file log is
   non-empty), (ii) separating blank spaces between the
   strings of the argument list and (iii) a trailing semicolon.
   Returns BS_SUCCESS, BS_BADARCH, BS_BADARG or BS_MEMALLOC.
*/
{
    char **av;
    int firstarg;
    StrSizeType len;
    char *newlog;

    if (sizeof(int) < 4)
        return BS_BADARCH;

    if (bsf == (BSFile *) 0)
        return BS_BADARG;
    if (argv == (char **) 0)
        return BS_BADARG;

    for (av= argv, len= 0; *av != (char *) 0; av++) {
        if (strlen(*av) > 0)
            len+= strlen(*av)+1;
    }
    if (len == (StrSizeType) 0)
        return BS_SUCCESS;
    if ((bsf->bsf_log != (char *) 0) && (strlen(bsf->bsf_log) > 0))
        len+= strlen(bsf->bsf_log);
    else
        len-= 1;
    len+= 2;

    if ((newlog= (char *) calloc((MemSizeType) len, sizeof(char))) == (char *) 0)
        return BS_MEMALLOC;
    if ((bsf->bsf_log != (char *) 0) && (strlen(bsf->bsf_log) > 0))
        (void) strcpy(newlog, bsf->bsf_log);
    else
        (void) strcpy(newlog, "");

    for (av= argv, firstarg= 1; *av != (char *) 0; av++) {
        if (strlen(*av) > 0) {
            if (firstarg) {
                if ((bsf->bsf_log != (char *) 0) && (strlen(bsf->bsf_log) > 0))
                    (void) strcat(newlog, "\n");
                firstarg= 0;
            }
            else
                (void) strcat(newlog, " ");
            (void) strcat(newlog, *av);
        }
    }
    (void) strcat(newlog, ";");

    if (bsf->bsf_log != (char *) 0)
        CFree((MemType *) bsf->bsf_log);
    bsf->bsf_log= newlog;

    return BS_SUCCESS;
}
Exemple #16
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;
}
Exemple #17
0
/*	Free H323RTPSet if its there
*/
void
GisFreeCallHandle(void *ptr)
{
	CallHandle *p = ptr;
	void *timerdata = NULL;
	SCC_EventBlock 		*evtPtr = NULL;

	if(p->max_call_duration_tid)
	{
		if(timerDeleteFromList(&localConfig.timerPrivate, p->max_call_duration_tid, &timerdata))
		{
			if(timerdata)
			{
				free(timerdata);
			}
		}
		p->max_call_duration_tid = 0;
	}

	switch(p->handleType)
	{
	case SCC_eH323CallHandle:
		if (H323inChan(p)[2].dataTypeHandle > 0 )
		{
			cmMeiEnter(UH323Globals()->hApp);
			freeNodeTree(UH323Globals()->hApp, H323inChan(p)[2].dataTypeHandle, 0);
			cmMeiExit(UH323Globals()->hApp);
		}
		if (H323inChan(p)[1].dataTypeHandle > 0 )
		{
			cmMeiEnter(UH323Globals()->hApp);
			freeNodeTree(UH323Globals()->hApp, H323inChan(p)[1].dataTypeHandle, 0);
			cmMeiExit(UH323Globals()->hApp);
		}
		if (H323localSet(p)!= NULL)
		{
	 		(CFree(callCache))(H323localSet(p));
		}
		if (H323remoteSet(p)!= NULL)
		{
	 		(CFree(callCache))(H323remoteSet(p));
		}
		if(H323remoteTCSNodeId(p))
		{
			cmMeiEnter(UH323Globals()->peerhApp);
			freeNodeTree(UH323Globals()->peerhApp, H323remoteTCSNodeId(p), 0);
			cmMeiExit(UH323Globals()->peerhApp);
		}
		if(H323tokenNodeId(p)>0)
		{
			cmMeiEnter(UH323Globals()->peerhApp);
			freeNodeTree(UH323Globals()->peerhApp, H323tokenNodeId(p), 0);
			cmMeiExit(UH323Globals()->peerhApp);
		}
		break;
	case SCC_eSipCallHandle:
		SipFreeSipCallHandle(SipCallHandle(p), sipCallCache->free);
		break;
	default:
		break;
	}

	if (p->realmInfo) 
	{
		RealmInfoFree(p->realmInfo, callCache->malloc);
	}

	if(p->evtList)
	{
		SCC_EventBlock 		*evtPtr = NULL;
		while((evtPtr = listDeleteFirstItem(p->evtList)))
		{
			H323FreeEvData((H323EventData *)(evtPtr->data));
			free(evtPtr);
		}
		listDestroy(p->evtList);
	}

	while ((evtPtr = listDeleteFirstItem(p->fcevtList)))
	{
		if (evtPtr->callDetails.callType == CAP_SIP)
		{
			SipFreeAppCallHandle(evtPtr->data);
			free(evtPtr);
		}
		else
		{
			H323FreeEvent(evtPtr);
		}
	}

	if(p->fcevtList)
	{
		listDestroy(p->fcevtList);
	}

	if (p->conf_id) (CFree(callCache))(p->conf_id);
	if (p->incoming_conf_id) (CFree(callCache))(p->incoming_conf_id);
	if (p->custID) (CFree(callCache))(p->custID);
	if (p->tg) (CFree(callCache))(p->tg);
	if (p->destTg) (CFree(callCache))(p->destTg);
	if (p->dtgInfo) (CFree(callCache))(p->dtgInfo);
	if (p->srccrname) (CFree(callCache))(p->srccrname);
	if (p->destcrname) (CFree(callCache))(p->destcrname);
	if (p->transitcrname) (CFree(callCache))(p->transitcrname);
	if (p->transRouteNumber) (CFree(callCache))(p->transRouteNumber);
	if(p->ogprefix)  (CFree(callCache))(p->ogprefix);

	if (p->vpnName)
	{
		free(p->vpnName);
	}
	
	if (p->zone)
	{
		free(p->zone);
	}

	if (p->cpname)
	{
		free(p->cpname);
	}

	GwFreeRejectList(p->destRejectList, CFree(callCache));
	p->destRejectList = NULL;

	SipFreeRemotecontactList(p->remotecontact_list);
	p->remotecontact_list = NULL;

	CdrArgsFree(p->prevcdr);

	(CFree(callCache))(p);
}