Ejemplo n.º 1
0
/**
 * FUNCTION: smlFreePcdata
 *
 * frees the Memory of an allocated Pcdata memory object
 *
 * IN:              SmlPcdataPtr_t
 *                  A Pointer to a PcData structure, which should be freed
 *
 * RETURN:          ---
 *
 */
SML_API void smlFreePcdata(SmlPcdataPtr_t pPcdata)
{
	if (! pPcdata)
		return;

	if (pPcdata->contentType == SML_PCDATA_EXTENSION) {
		switch ((int)pPcdata->extension) {
#ifdef __USE_METINF__
			case SML_EXT_METINF:
				smlFreeMetinfMetinf(pPcdata->content);
				smlLibFree(pPcdata);
				break;
#endif
#ifdef __USE_DEVINF__
			case SML_EXT_DEVINF:
				smlFreeDevInfDevInf(pPcdata->content);
				smlLibFree(pPcdata);
				break;
#endif
		}
		return;
	}

	if (pPcdata->content)
		smlLibFree(pPcdata->content);

	smlLibFree(pPcdata);
}
Ejemplo n.º 2
0
Ret_t buildDevInfDevInfCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) {
    XltDecScannerPtr_t pScanner;
    SmlDevInfDevInfPtr_t pElem = NULL;
    Ret_t rc;

    pScanner = pDecoder->scanner;

    if (*ppElem != NULL)
        return SML_ERR_XLT_INVAL_SYNCML_DOC;

    if (IS_EMPTY(pScanner->curtok)) {
        *ppElem = pElem;
        return SML_ERR_OK;
    }

    if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
        smlLibFree(pElem);
        return rc;
    }

    switch (pScanner->curtok->tagid) {
        case TN_DEVINF_DEVINF:
            rc = buildDevInfDevInfContent(pDecoder, (VoidPtr_t)&pElem);
            break;
        default:
            rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
    }
    if (rc != SML_ERR_OK) {
        smlLibFree(pElem);
        return rc;
    }
    *ppElem = pElem;

    return SML_ERR_OK;
}
Ejemplo n.º 3
0
/**
 * FUNCTION: smlPcdataDup
 *
 * Duplicates a Pcdata memory object
 *
 * IN:              SmlPcdataPtr_t
 *                  A Pointer to the original PcData structure
 *
 * RETURN:          SmlPcdataPtr_t
 *                  A Pointer to the copy of the PcData structure
 *
 */
SML_API SmlPcdataPtr_t smlPcdataDup(SmlPcdataPtr_t pcdata) 
{
	/* Definitions */ 
	SmlPcdataPtr_t newPcdata;

	/* Invalid Input */ 
	if (! pcdata) 
		return NULL;

	/* Allocate the new pcdata memory object */
	newPcdata = (SmlPcdataPtr_t)smlLibMalloc((MemSize_t)sizeof(SmlPcdata_t));
	if (! newPcdata) 
		return NULL;
	smlLibMemset (newPcdata, 0, (MemSize_t)sizeof(SmlPcdata_t));

	/* Set the PcData Structure */
	newPcdata->contentType = pcdata->contentType;
	newPcdata->length = pcdata->length;
	newPcdata->content =(VoidPtr_t)smlLibMalloc((MemSize_t)pcdata->length+1);
	if (newPcdata->content ==NULL)
	{
	    smlLibFree(newPcdata->content);
        smlLibFree(newPcdata);
        return NULL;
	} 
	smlLibMemset(newPcdata->content, 0, (MemSize_t)((pcdata->length)+1));	
	smlLibMemcpy(newPcdata->content, pcdata->content, (MemSize_t)pcdata->length);

	return newPcdata;
}
Ejemplo n.º 4
0
Ret_t buildDevInfDSMemCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) {
    XltDecScannerPtr_t pScanner;
    SmlDevInfDSMemPtr_t pElem;
    Ret_t rc;

    pScanner = pDecoder->scanner;

    if (*ppElem != NULL)
        return SML_ERR_XLT_INVAL_SYNCML_DOC;

    if ((pElem = (SmlDevInfDSMemPtr_t)smlLibMalloc(sizeof(SmlDevInfDSMem_t))) == NULL)
        return SML_ERR_NOT_ENOUGH_SPACE;
    smlLibMemset(pElem, 0, sizeof(SmlDevInfDSMem_t));

    if (IS_EMPTY(pScanner->curtok)) {
        *ppElem = pElem;
        return SML_ERR_OK;
    }

    if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
        smlLibFree(pElem);
        return rc;
    }

    while (pScanner->curtok->type != TOK_TAG_END) {
        switch (pScanner->curtok->tagid) {
    		    /* PCDATA elements */
            case TN_DEVINF_SHAREDMEM:
                // %%% luz:2003-04-28: made work as a flag
                pElem->flags |= SmlDevInfSharedMem_f;
                // rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->shared);
                break;
            case TN_DEVINF_MAXMEM:
                rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->maxmem);
                break;
            case TN_DEVINF_MAXID:
                rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->maxid);
                break;
            default:
                rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
        }
        if (rc != SML_ERR_OK) {
            smlLibFree(pElem);
            return rc;
        }
        if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
            smlLibFree(pElem);
            return rc;
        }
    }
    *ppElem = pElem;

    return SML_ERR_OK;
}
static Ret_t
_destroy(XltUtilStackPtr_t pStack)
{
    ArrayStackPtr_t pStackPriv; 

    if (pStack == NULL)
        return SML_ERR_OK;

    pStackPriv = (ArrayStackPtr_t)pStack; 

    smlLibFree(pStackPriv->array);
    smlLibFree(pStackPriv);
    return SML_ERR_OK;
}
Ejemplo n.º 6
0
Ret_t buildDevInfXmitCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) {
    XltDecScannerPtr_t pScanner;
    SmlDevInfXmitPtr_t pXmit;
    Ret_t rc;

    pScanner = pDecoder->scanner;

    if (*ppElem != NULL)
        return SML_ERR_XLT_INVAL_SYNCML_DOC;

    if ((pXmit = (SmlDevInfXmitPtr_t)smlLibMalloc(sizeof(SmlDevInfXmit_t))) == NULL)
        return SML_ERR_NOT_ENOUGH_SPACE;
    smlLibMemset(pXmit, 0, sizeof(SmlDevInfXmit_t));

    if (IS_EMPTY(pScanner->curtok)) {
        *ppElem = pXmit;
        return SML_ERR_OK;
    }

    if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
        smlLibFree(pXmit);
        return rc;
    }

    while (pScanner->curtok->type != TOK_TAG_END) {
        switch (pScanner->curtok->tagid) {
		    /* PCDATA elements */
            case TN_DEVINF_CTTYPE:
                rc = buildPCData(pDecoder, (VoidPtr_t)&pXmit->cttype);
                break;
            case TN_DEVINF_VERCT:
                rc = buildPCData(pDecoder, (VoidPtr_t)&pXmit->verct);
                break;
            default:
                rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
        }
        if (rc != SML_ERR_OK) {
            smlLibFree(pXmit);
            return rc;
        }
        if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
            smlLibFree(pXmit);
            return rc;
        }
    }
    *ppElem = pXmit;

    return SML_ERR_OK;
}
Ejemplo n.º 7
0
Ret_t buildDevInfExtCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) {
    XltDecScannerPtr_t pScanner;
    SmlDevInfExtPtr_t pElem;
    Ret_t rc;

    pScanner = pDecoder->scanner;

    if (*ppElem != NULL)
        return SML_ERR_XLT_INVAL_SYNCML_DOC;

    if ((pElem = (SmlDevInfExtPtr_t)smlLibMalloc(sizeof(SmlDevInfExt_t))) == NULL)
        return SML_ERR_NOT_ENOUGH_SPACE;
    smlLibMemset(pElem, 0, sizeof(SmlDevInfExt_t));

    if (IS_EMPTY(pScanner->curtok)) {
        *ppElem = pElem;
        return SML_ERR_OK;
    }

    if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
        smlLibFree(pElem);
        return rc;
    }

    while (pScanner->curtok->type != TOK_TAG_END) {
        switch (pScanner->curtok->tagid) {
            case TN_DEVINF_XNAM:
                rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->xnam);
                break;
            case TN_DEVINF_XVAL:
                rc = buildPCDataList(pDecoder, (VoidPtr_t)&pElem->xval);
                break;
            default:
                rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
        }
        if (rc != SML_ERR_OK) {
            smlLibFree(pElem);
            return rc;
        }
        if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
            smlLibFree(pElem);
            return rc;
        }
    }
    *ppElem = pElem;

    return SML_ERR_OK;
}
Ejemplo n.º 8
0
SML_API void smlFreeDevInfDatastoreList(SmlDevInfDatastoreListPtr_t data) {
    if (!data) return;
    smlFreeDevInfDatastore(data->data);
    smlFreeDevInfDatastoreList(data->next);
    smlLibFree(data);
    return;
}
Ejemplo n.º 9
0
SML_API void smlFreeMetinfAnchor(SmlMetInfAnchorPtr_t data) {
    if (!data) return;
	smlFreePcdata(data->last);
	smlFreePcdata(data->next);
	smlLibFree(data);
	return;
}
Ejemplo n.º 10
0
SML_API void smlFreePcdataList(SmlPcdataListPtr_t list) {
	if (!list) return;
	smlFreePcdataList(list->next);
	smlFreePcdata(list->data);
	smlLibFree(list);
	return;
}
Ejemplo n.º 11
0
/**
 * FUNCTION: smlLibRealloc
 *
 * Changes size of preallocated space for memory object "pObject"
 * to the new size specified by "constSize".
 *
 * If the new size is larger than the old size, the old contents 
 * is not changed. Additionally space is added at the the end of 
 * "pObject". The new allocated space is not initialized 
 * to any special value.
 * If the new size is smaller than the old size, the unused space
 * is discarded.
 *
 * If "pObject" is a NULL pointer, this function behaves just like 
 * smlLibMalloc().
 * If "pObject" does not point to a previously allocated memory area, 
 * the behavior is undefined.
 * If "constSize" is 0, a NULL pointer is returned and the space 
 * which "pObject" points to is freed up.
 *
 * Returns a pointer to the first byte of the resized object.
 * If no new memory could be allocated, a NULL Pointer is returned 
 * without changing the memory object "pObject" (Nothing happens to the content).
 *
 * IN/OUT           void *pObject,      memory object, which size should be changed
 * IN:              MemSize_t constSize new size the memory object shall use
 * RETURN:          void*               Pointer to memory object, which size has been
 *                                      be changed
 *                                      NULL, if not successfull or
 *                                            if constSize==0
 */
SML_API void *smlLibRealloc(void *pObject, MemSize_t constSize)
{
#ifdef __PALM_OS__
	VoidPtr_t	_new_object;
	MemSize_t 	_old_size;    
  
  	// It's a malloc!
  	if (pObject == NULL)
    		return smlLibMalloc(constSize);
    
  	_old_size = MemPtrSize(pObject); 
  	if (constSize <= _old_size) {
     		// make it smaller
     		MemPtrResize(pObject, constSize);
     		_new_object = pObject;
  	} else {
     		// maker it larger (we need to allocate new memory somewhere else)
     		_new_object = smlLibMalloc(constSize);
     		if (_new_object != NULL) {
        		smlLibMemmove(_new_object, pObject, _old_size);
        		smlLibFree(pObject);
     		}
  	}           

	return _new_object;
#else
  return DmReallocMem(pObject, (UINT32)constSize);
	
#endif
}
Ejemplo n.º 12
0
SML_API void smlFreeDevInfDSMem(SmlDevInfDSMemPtr_t data) {
    if (!data) return;
    // %%%luz:2003-04-28: this is now a flag! smlFreePcdata(data->shared);
    smlFreePcdata(data->maxmem);
    smlFreePcdata(data->maxid);
    smlLibFree(data);
}
Ejemplo n.º 13
0
Ret_t
xltUtilCreateStack(XltUtilStackPtr_t *ppStack, const Long_t size)
{
    ArrayStackPtr_t pStack;

    if (size <= 0)
        return SML_ERR_WRONG_PARAM;
        if ((pStack = (ArrayStackPtr_t)smlLibMalloc(sizeof(ArrayStack_t))) == NULL) {
 		*ppStack = NULL;
           return SML_ERR_NOT_ENOUGH_SPACE;
 	}

    pStack->top = _top;
    pStack->pop = _pop;
    pStack->push = _push;
    pStack->destroy = _destroy;
    pStack->topidx = -1;
    pStack->size = size;
    pStack->chunksize = size;
    pStack->array = NULL;
    if ((pStack->array = (XltUtilStackItem_t*)smlLibMalloc(size * sizeof(XltUtilStackItem_t))) == NULL) {
 		*ppStack = NULL;
 		smlLibFree(pStack);
        return SML_ERR_NOT_ENOUGH_SPACE;
 	}

    *ppStack = (XltUtilStackPtr_t)pStack;
	
	

    return SML_ERR_OK;
}
Ejemplo n.º 14
0
/**
 * FUNCTION: smlSetSyncMLOptions
 *
 * change the option settings for syncML
 *
 * IN:              SyncMLOptionsPtr_t
 *                  options to be applied for the toolkit
 *
 * RETURN:          Ret_t 
 *                  Return Code
 */
SML_API Ret_t smlSetSyncMLOptions(SmlOptionsPtr_t pCoreOptions) {


  /* ---- Definitions --- */
  SmlOptionsPtr_t pCoreOptionsCopy;
 

  /* --- Check pOptions, which have been passed by the application --- */
  if (!pCoreOptions)
	  return SML_ERR_WRONG_USAGE;

  
  /* --- free SyncML options --- */
  smlLibFree(pGlobalAnchor->syncmlOptions); 
  pGlobalAnchor->syncmlOptions = NULL; 
  /* --- Use a copy of pCoreOptions --- */
  pCoreOptionsCopy =  (SmlOptionsPtr_t)smlLibMalloc((MemSize_t)sizeof(SmlOptions_t));
  if (pCoreOptionsCopy==NULL) return SML_ERR_NOT_ENOUGH_SPACE;
  smlLibMemcpy(pCoreOptionsCopy,pCoreOptions,(MemSize_t)sizeof(SmlOptions_t));


  /* --- set new SyncML options --- */
  pGlobalAnchor->syncmlOptions  = pCoreOptionsCopy;  // set the options,passed from the application 
  
  return SML_ERR_OK;

}
Ejemplo n.º 15
0
/**
 * Changes size of preallocated space for memory object "pObject"
 * to the new size specified by "constSize".
 *
 * If the new size is larger than the old size, the old contents
 * is not changed. Additionally space is added at the the end of
 * "pObject". The new allocated space is not initialized
 * to any special value.
 * If the new size is smaller than the old size, the unused space
 * is discarded.
 *
 * If "pObject" is a NULL pointer, this function behaves just like
 * smlLibMalloc().
 * If "pObject" does not point to a previously allocated memory area,
 * the behavior is undefined.
 * If "constSize" is 0, a NULL pointer is returned and the space
 * which "pObject" points to is freed up.
 *
 * Returns a pointer to the first byte of the resized object.
 * If no new memory could be allocated, a NULL Pointer is returned
 * without changing the memory object "pObject" (Nothing happens to the content).
 *
 * @param pObject (IN/OUT)
 *        memory object, which size should be changed
 * @param constSize (IN)
 *        new size the memory object shall use
 * @return void pointer to memory object, which size has been be changed\n
 *         NULL, if not successfull or if constSize==0
 */
SML_API void *smlLibRealloc(void *pObject, MemSize_t constSize)
{
#ifdef __PALM_OS__
  VoidPtr_t _new_object;
  MemSize_t   _old_size;

    // It's a malloc!
    if (pObject == NULL)
        return smlLibMalloc(constSize);

    _old_size = MemPtrSize(pObject);
    if (constSize <= _old_size) {
        // make it smaller
        MemPtrResize(pObject, constSize);
        _new_object = pObject;
    } else {
        // maker it larger (we need to allocate new memory somewhere else)
        _new_object = smlLibMalloc(constSize);
        if (_new_object != NULL) {
            smlLibMemmove(_new_object, pObject, _old_size);
            smlLibFree(pObject);
        }
    }

  return _new_object;
#else
  // %%% luz 2002-10-02
  #ifdef MEMORY_PROFILING
  return sysync_realloc(pObject, constSize);
  #else
  return realloc(pObject, constSize);
  #endif
#endif
}
Ejemplo n.º 16
0
SML_API void smlFreeDevInfCtcapList(SmlDevInfCtcapListPtr_t data) {
    if (!data) return;

    smlFreeDevInfCTCap(data->data);
    smlFreeDevInfCtcapList(data->next);
    smlLibFree(data);
}
Ejemplo n.º 17
0
// free table obtained with getDtdTable()
void freeDtdTable(DtdPtr_t tbl)
{
  #ifndef NOWSM
  // only with WSM this is an allocated table
  smlLibFree(tbl);
  #endif
}
Ejemplo n.º 18
0
SML_API void smlFreeMetinfMem(SmlMetInfMemPtr_t data) {
    if (!data) return;
	smlFreePcdata(data->shared);
	smlFreePcdata(data->free);
	smlFreePcdata(data->freeid);
	smlLibFree(data);
	return;
}
Ejemplo n.º 19
0
SML_API void smlFreeChalPtr(SmlChalPtr_t pChal)
{
	if (! pChal)
		return;

	smlFreePcdata(pChal->meta);

	smlLibFree(pChal);
}
Ejemplo n.º 20
0
SML_API void smlFreeDevInfCTData(SmlDevInfCTDataPtr_t data) {
    if (!data) return;
    smlFreePcdata(data->name);
    smlFreePcdata(data->dname);
    smlFreePcdataList(data->valenum);
    smlFreePcdata(data->datatype);
    smlFreePcdata(data->size);
    smlLibFree(data);
}
Ejemplo n.º 21
0
SML_API void smlFreeCredPtr(SmlCredPtr_t pCred)
{
	if (! pCred)
		return;

	smlFreePcdata(pCred->meta);
	smlFreePcdata(pCred->data);

	smlLibFree(pCred);
}
Ejemplo n.º 22
0
SML_API void smlFreeAtomic(SmlAtomicPtr_t pAtomic)
{
	if (! pAtomic)
		return;

	smlFreePcdata(pAtomic->cmdID);
	smlFreePcdata(pAtomic->meta);

	smlLibFree(pAtomic);
}
Ejemplo n.º 23
0
SML_API void smlFreeMapItemPtr(SmlMapItemPtr_t pMapItem)
{
	if (! pMapItem)
		return;

	smlFreeSourceTargetPtr(pMapItem->source);
	smlFreeSourceTargetPtr(pMapItem->target);

	smlLibFree(pMapItem);
}
Ejemplo n.º 24
0
SML_API void smlFreeSourceTargetPtr(SmlSourcePtr_t pSourceTarget)
{
	if (! pSourceTarget)
		return;

	smlFreePcdata(pSourceTarget->locURI);
	smlFreePcdata(pSourceTarget->locName);

	smlLibFree(pSourceTarget);
}
Ejemplo n.º 25
0
SML_API void smlFreeSourceRefList(SmlSourceRefListPtr_t pSourceRefList)
{
	SmlSourceRefListPtr_t	pTmp;

	while (pSourceRefList) {
		pTmp = pSourceRefList->next;
		smlFreePcdata(pSourceRefList->sourceRef);
		smlLibFree(pSourceRefList);
		pSourceRefList = pTmp;
	}
}
Ejemplo n.º 26
0
SML_API void smlFreeMapItemList(SmlMapItemListPtr_t pMapItemList)
{
	SmlMapItemListPtr_t	pTmp;

	while (pMapItemList) {
		pTmp = pMapItemList->next;
		smlFreeMapItemPtr(pMapItemList->mapItem);
		smlLibFree(pMapItemList);
		pMapItemList = pTmp;
	}
}
Ejemplo n.º 27
0
SML_API void smlFreeItemList(SmlItemListPtr_t pItemList)
{
	SmlItemListPtr_t	pTmp;

	while (pItemList) {
		pTmp = pItemList->next;
		smlFreeItemPtr(pItemList->item);
		smlLibFree(pItemList);
		pItemList = pTmp;
	}
}
Ejemplo n.º 28
0
SML_API void smlFreeTargetRefList(SmlTargetRefListPtr_t pTargetRefList)
{
	SmlTargetRefListPtr_t	pTmp;

	while (pTargetRefList) {
		pTmp = pTargetRefList->next;
		smlFreePcdata(pTargetRefList->targetRef);
		smlLibFree(pTargetRefList);
		pTargetRefList = pTmp;
	}
}
Ejemplo n.º 29
0
SML_API void smlFreeSourceList(SmlSourceListPtr_t pSourceList)
{
	SmlSourceListPtr_t	pTmp;

	while (pSourceList) {
		pTmp = pSourceList->next;
		smlFreeSourceTargetPtr(pSourceList->source);
		smlLibFree(pSourceList);
		pSourceList = pTmp;
	}
}
Ejemplo n.º 30
0
SML_API void smlFreeItemPtr(SmlItemPtr_t pItem)
{
	if (! pItem)
		return;

	smlFreePcdata(pItem->meta);
	smlFreePcdata(pItem->data);

	smlFreeSourceTargetPtr(pItem->source);
	smlFreeSourceTargetPtr(pItem->target);

	smlLibFree(pItem);
}