/** * 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; }
/** * 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 }
/** * 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 }
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; }
SML_API SmlDevInfDatastorePtr_t smlAllocDevInfDatastore() { SmlDevInfDatastorePtr_t p = (SmlDevInfDatastorePtr_t)smlLibMalloc(sizeof(SmlDevInfDatastore_t)); if (p == NULL) return NULL; smlLibMemset(p, 0, sizeof(SmlDevInfDatastore_t)); p->sourceref = smlAllocPcdata(); if (p->sourceref == NULL) { smlFreeDevInfDatastore(p); return NULL; } p->rxpref = smlAllocDevInfXmit(); if (p->rxpref == NULL) { smlFreeDevInfDatastore(p); return NULL; } p->txpref = smlAllocDevInfXmit(); if (p->txpref == NULL) { smlFreeDevInfDatastore(p); return NULL; } p->synccap = smlAllocDevInfSyncCap(); if (p->synccap == NULL) { smlFreeDevInfDatastore(p); return NULL; } return p; }
SML_API SmlUnknownProtoElementPtr_t smlAllocUnknownProtoElement() { SmlUnknownProtoElementPtr_t p = (SmlUnknownProtoElementPtr_t)smlLibMalloc(sizeof(SmlUnknownProtoElement_t)); if (p == 0) return NULL; smlLibMemset(p, 0, sizeof(SmlUnknownProtoElement_t)); p->elementType = SML_PE_UNDEF; return p; }
SML_API SmlStatusPtr_t smlAllocStatus() { SmlStatusPtr_t p = (SmlStatusPtr_t)smlLibMalloc(sizeof(SmlStatus_t)); if (p == 0) return NULL; smlLibMemset(p, 0, sizeof(SmlStatus_t)); p->elementType = SML_PE_STATUS; p->cmdID = smlAllocPcdata(); if (p->cmdID == NULL) { smlFreeStatus(p); return NULL; } p->msgRef = smlAllocPcdata(); if (p->msgRef == NULL) { smlFreeStatus(p); return NULL; } p->cmdRef = smlAllocPcdata(); if (p->cmdRef == NULL) { smlFreeStatus(p); return NULL; } p->cmd = smlAllocPcdata(); if (p->cmd == NULL) { smlFreeStatus(p); return NULL; } p->data = smlAllocPcdata(); if (p->data == NULL) { smlFreeStatus(p); return NULL; } return p; }
SML_API SmlSearchPtr_t smlAllocSearch() { SmlSearchPtr_t p = (SmlSearchPtr_t)smlLibMalloc(sizeof(SmlSearch_t)); if (p == 0) return NULL; smlLibMemset(p, 0, sizeof(SmlSearch_t)); p->elementType = SML_PE_SEARCH; p->cmdID = smlAllocPcdata(); if (p->cmdID == NULL) { smlFreeSearch(p); return NULL; } p->meta = smlAllocPcdata(); if (p->meta == NULL) { smlFreeSearch(p); return NULL; } p->data = smlAllocPcdata(); if (p->data == NULL) { smlFreeSearch(p); return NULL; } p->sourceList = smlAllocSourceList(); if (p->sourceList == NULL) { smlFreeSearch(p); return NULL; } return p; }
SML_API SmlMapPtr_t smlAllocMap() { SmlMapPtr_t p = (SmlMapPtr_t)smlLibMalloc(sizeof(SmlMap_t)); if (p == 0) return NULL; smlLibMemset(p, 0, sizeof(SmlMap_t)); p->elementType = SML_PE_MAP; p->cmdID = smlAllocPcdata(); if (p->cmdID == NULL) { smlFreeMap(p); return NULL; } p->target = smlAllocTarget(); if (p->target == NULL) { smlFreeMap(p); return NULL; } p->source = smlAllocSource(); if (p->source == NULL) { smlFreeMap(p); return NULL; } p->mapItemList = smlAllocMapItemList(); if (p->mapItemList == NULL) { smlFreeMap(p); return NULL; } return p; }
/** * 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; }
// %%% luz:2003-04-24: added syncmlvers parameter // %%% luz:2003-07-31: changed to vers enum Ret_t getExtName(SmlPcdataExtension_t ext, String_t *name, SmlVersion_t vers) { DtdPtr_t dtdhead = getDtdTable(); DtdPtr_t dtd = dtdhead; const char *dtdname; if (!dtdhead) return -1; for (;dtd->ext != SML_EXT_LAST; dtd++) { if (!dtd->name) continue; /* skip empty names (should not appear but better be on the safe side) */ if (dtd->ext == ext) { String_t _tmp; // this is the default dtdname=dtd->name; // %%% luz:2003-04-24: added dynamic generation of namespace according to SyncML version if (ext==SML_EXT_UNDEFINED && vers!=SML_VERS_UNDEF) { // this requests SyncML namespace dtdname=SyncMLNamespaces[vers]; } _tmp = smlLibMalloc(smlLibStrlen(dtdname)+1); if (!_tmp) { freeDtdTable(dtdhead); return SML_ERR_NOT_ENOUGH_SPACE; } smlLibStrcpy(_tmp, dtdname); freeDtdTable(dtdhead); *name = _tmp; return SML_ERR_OK; } } freeDtdTable(dtdhead); return -1; }
DtdPtr_t getDtdTable() { #ifdef NOWSM // NOWSM method, table is const, just return a pointer static const Dtd_t XltDtdTbl[] = { { "SYNCML:SYNCML1.0", SML_EXT_UNDEFINED}, // %%% note that this is the default, will be override by syncml version specific string from { "syncml:metinf", SML_EXT_METINF}, { "syncml:devinf", SML_EXT_DEVINF}, { NULL, SML_EXT_LAST} }; return (DtdPtr_t)XltDtdTbl; #else // WSM method wasting a lot of memory DtdPtr_t _tmpPtr; Dtd_t XltDtdTbl[] = { { "SYNCML:SYNCML1.0", SML_EXT_UNDEFINED}, { "syncml:metinf", SML_EXT_METINF}, { "syncml:devinf", SML_EXT_DEVINF}, { NULL, SML_EXT_LAST} }; _tmpPtr = NULL; _tmpPtr = (DtdPtr_t)smlLibMalloc(sizeof(XltDtdTbl)); if (_tmpPtr == NULL) return NULL; smlLibMemcpy(_tmpPtr, &XltDtdTbl, sizeof(XltDtdTbl)); return _tmpPtr; #endif }
/* decoder callbacks */ Ret_t buildDmTndCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) { XltDecScannerPtr_t pScanner; SmlDmTndPtr_t pDmTnd; Ret_t rc; pScanner = pDecoder->scanner; if (*ppElem != NULL) return SML_ERR_XLT_INVAL_SYNCML_DOC; if ((pDmTnd = (SmlDmTndPtr_t)smlLibMalloc(sizeof(SmlDmTnd_t))) == NULL) return SML_ERR_NOT_ENOUGH_SPACE; smlLibMemset(pDmTnd, 0, sizeof(SmlDmTnd_t)); if (IS_EMPTY(pScanner->curtok)) { *ppElem = pDmTnd; return SML_ERR_OK; } if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) { smlFreeDmTnd(pDmTnd); return rc; } while (pScanner->curtok->type != TOK_TAG_END) { switch (pScanner->curtok->tagid) { case TN_DMTND_MgmtTree: break; case TN_DMTND_VerDTD: rc = buildPCData(pDecoder, (VoidPtr_t)&pDmTnd->verdtd); break; case TN_DMTND_Man: rc = buildPCData(pDecoder, (VoidPtr_t)&pDmTnd->man); break; case TN_DMTND_Mod: rc = buildPCData(pDecoder, (VoidPtr_t)&pDmTnd->mod); break; case TN_DMTND_Node: rc = buildDmTndNodeList(pDecoder, (VoidPtr_t)&pDmTnd->nodelist); break; default: KCDBG(">>>>> buildDmTndDFPropsCmd: Unkown token: %d <<<<<\n", pScanner->curtok->tagid); rc = SML_ERR_XLT_INVAL_SYNCML_DOC; } if (rc != SML_ERR_OK) { smlFreeDmTnd(pDmTnd); return rc; } if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) { smlFreeDmTnd(pDmTnd); return rc; } } *ppElem = pDmTnd; return SML_ERR_OK; }
Ret_t buildMetInfMemCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) { XltDecScannerPtr_t pScanner; SmlMetInfMemPtr_t pMem; Ret_t rc; pScanner = pDecoder->scanner; if (*ppElem != NULL) return SML_ERR_XLT_INVAL_SYNCML_DOC; if ((pMem = (SmlMetInfMemPtr_t)smlLibMalloc(sizeof(SmlMetInfMem_t))) == NULL) return SML_ERR_NOT_ENOUGH_SPACE; smlLibMemset(pMem, 0, sizeof(SmlMetInfMem_t)); if (IS_EMPTY(pScanner->curtok)) { *ppElem = pMem; return SML_ERR_OK; } if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) { smlFreeMetinfMem(pMem); //smlLibFree(pMem); return rc; } while (pScanner->curtok->type != TOK_TAG_END) { switch (pScanner->curtok->tagid) { /* PCDATA elements */ case TN_METINF_SHAREDMEM: rc = buildPCData(pDecoder, (VoidPtr_t)&pMem->shared); break; case TN_METINF_FREEMEM: rc = buildPCData(pDecoder, (VoidPtr_t)&pMem->free); break; case TN_METINF_FREEID: rc = buildPCData(pDecoder, (VoidPtr_t)&pMem->freeid); break; default: rc = SML_ERR_XLT_INVAL_SYNCML_DOC; } if (rc != SML_ERR_OK) { smlFreeMetinfMem(pMem); //smlLibFree(pMem); return rc; } if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) { smlFreeMetinfMem(pMem); //smlLibFree(pMem); return rc; } } *ppElem = pMem; return SML_ERR_OK; }
/* decoder callbacks */ Ret_t buildDmTndTypeCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) { XltDecScannerPtr_t pScanner; SmlDmTndTypePtr_t pDmTndType; Ret_t rc; pScanner = pDecoder->scanner; if (*ppElem != NULL) return SML_ERR_XLT_INVAL_SYNCML_DOC; if ((pDmTndType = (SmlDmTndTypePtr_t)smlLibMalloc(sizeof(SmlDmTndType_t))) == NULL) return SML_ERR_NOT_ENOUGH_SPACE; smlLibMemset(pDmTndType, 0, sizeof(SmlDmTndType_t)); if (IS_EMPTY(pScanner->curtok)) { *ppElem = pDmTndType; return SML_ERR_OK; } if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) { smlFreeDmTndType(pDmTndType); return rc; } while (pScanner->curtok->type != TOK_TAG_END) { switch (pScanner->curtok->tagid) { case TN_DMTND_MIME: rc = buildPCData(pDecoder, (VoidPtr_t)&pDmTndType->mime); break; case TN_DMTND_DDFName: rc = buildPCData(pDecoder, (VoidPtr_t)&pDmTndType->ddfname); break; default: KCDBG(">>>>> Unkown token: %d <<<<<\n", pScanner->curtok->tagid); rc = SML_ERR_XLT_INVAL_SYNCML_DOC; } if (rc != SML_ERR_OK) { smlFreeDmTndType(pDmTndType); return rc; } if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) { smlFreeDmTndType(pDmTndType); return rc; } if (pScanner->curtok->type != TOK_TAG_END) { smlFreeDmTndType(pDmTndType); return SML_ERR_XLT_INVAL_SYNCML_DOC; } } *ppElem = pDmTndType; return SML_ERR_OK; }
SML_API SmlDevInfCTDataPropPtr_t smlAllocDevInfCTDataProp() { SmlDevInfCTDataPropPtr_t p = (SmlDevInfCTDataPropPtr_t)smlLibMalloc(sizeof(SmlDevInfCTDataProp_t)); if (p == NULL) return NULL; smlLibMemset(p, 0, sizeof(SmlDevInfCTDataProp_t)); p->prop = smlAllocDevInfCTData(); if (p->prop == NULL) { smlFreeDevInfCTDataProp(p); return NULL; } return p; }
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; }
SML_API SmlItemListPtr_t smlAllocItemList() { SmlItemListPtr_t p = (SmlItemListPtr_t)smlLibMalloc(sizeof(SmlItemList_t)); if (p == NULL) return NULL; smlLibMemset(p, 0, sizeof(SmlItemList_t)); p->item = smlAllocItem(); if (p->item == NULL) { smlFreeItemList(p); return NULL; } return p; }
SML_API SmlSourcePtr_t smlAllocSource() { SmlSourcePtr_t p = (SmlSourcePtr_t)smlLibMalloc(sizeof(SmlSource_t)); if (p == NULL) return NULL; smlLibMemset(p, 0, sizeof(SmlSource_t)); p->locURI = smlAllocPcdata(); if (p->locURI == NULL) { smlFreeSourceTargetPtr(p); return NULL; } return p; }
SML_API SmlSourceListPtr_t smlAllocSourceList() { SmlSourceListPtr_t p = (SmlSourceListPtr_t)smlLibMalloc(sizeof(SmlSourceList_t)); if (p == NULL) return NULL; smlLibMemset(p, 0, sizeof(SmlSourceList_t)); p->source = smlAllocSource(); if (p->source == NULL) { smlFreeSourceList(p); return NULL; } return p; }
SML_API SmlPcdataListPtr_t smlAllocPcdataList() { SmlPcdataListPtr_t p = (SmlPcdataListPtr_t)smlLibMalloc(sizeof(SmlPcdataList_t)); if (p == NULL) return NULL; smlLibMemset(p, 0, sizeof(SmlPcdataList_t)); p->data = smlAllocPcdata(); if (p->data == NULL) { smlFreePcdataList(p); return NULL; } return p; }
SML_API SmlCredPtr_t smlAllocCred() { SmlCredPtr_t p = (SmlCredPtr_t)smlLibMalloc(sizeof(SmlCred_t)); if (p == NULL) return NULL; smlLibMemset(p, 0, sizeof(SmlCred_t)); p->data = smlAllocPcdata(); if (p->data == NULL) { smlFreeCredPtr(p); return NULL; } return p; }
SML_API SmlTargetRefListPtr_t smlAllocTargetRefList() { SmlTargetRefListPtr_t p = (SmlTargetRefListPtr_t)smlLibMalloc(sizeof(SmlTargetRefList_t)); if (p == 0) return NULL; smlLibMemset(p, 0, sizeof(SmlTargetRefList_t)); p->targetRef = smlAllocPcdata(); if (p->targetRef == NULL) { smlFreeTargetRefList(p); return NULL; } return p; }
SML_API SmlDevInfDatastoreListPtr_t smlAllocDevInfDatastoreList() { SmlDevInfDatastoreListPtr_t p = (SmlDevInfDatastoreListPtr_t)smlLibMalloc(sizeof(SmlDevInfDatastoreList_t)); if (p == NULL) return NULL; smlLibMemset(p, 0, sizeof(SmlDevInfDatastoreList_t)); p->data = smlAllocDevInfDatastore(); if (p->data == NULL) { smlFreeDevInfDatastoreList(p); return NULL; } return p; }
SML_API SmlMetInfAnchorPtr_t smlAllocMetInfAnchor() { SmlMetInfAnchorPtr_t p = (SmlMetInfAnchorPtr_t)smlLibMalloc(sizeof(SmlMetInfAnchor_t)); if (p == NULL) return NULL; smlLibMemset(p, 0, sizeof(SmlMetInfAnchor_t)); p->next = smlAllocPcdata(); if (p->next == NULL) { smlFreeMetinfAnchor(p); return NULL; } return p; }
SML_API SmlDevInfExtPtr_t smlAllocDevInfExt() { SmlDevInfExtPtr_t p = (SmlDevInfExtPtr_t)smlLibMalloc(sizeof(SmlDevInfExt_t)); if (p == NULL) return NULL; smlLibMemset(p, 0, sizeof(SmlDevInfExt_t)); p->xnam = smlAllocPcdata(); if (p->xnam == NULL) { smlFreeDevInfExt(p); return NULL; } return p; }
SML_API SmlDevInfSyncCapPtr_t smlAllocDevInfSyncCap() { SmlDevInfSyncCapPtr_t p = (SmlDevInfSyncCapPtr_t)smlLibMalloc(sizeof(SmlDevInfSyncCap_t)); if (p == NULL) return NULL; smlLibMemset(p, 0, sizeof(SmlDevInfSyncCap_t)); p->synctype = smlAllocPcdataList(); if (p->synctype == NULL) { smlFreeDevInfSynccap(p); return NULL; } return p; }
SML_API SmlSyncPtr_t smlAllocSync() { SmlSyncPtr_t p = (SmlSyncPtr_t)smlLibMalloc(sizeof(SmlSync_t)); if (p == NULL) return NULL; smlLibMemset(p, 0, sizeof(SmlSync_t)); p->elementType = SML_PE_SYNC_START; p->cmdID = smlAllocPcdata(); if (p->cmdID == NULL) { smlFreeSync(p); return NULL; } return p; }
/* decoder callbacks */ Ret_t buildMetInfAnchorCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) { XltDecScannerPtr_t pScanner; SmlMetInfAnchorPtr_t pAnchor; Ret_t rc; pScanner = pDecoder->scanner; if (*ppElem != NULL) return SML_ERR_XLT_INVAL_SYNCML_DOC; if ((pAnchor = (SmlMetInfAnchorPtr_t)smlLibMalloc(sizeof(SmlMetInfAnchor_t))) == NULL) return SML_ERR_NOT_ENOUGH_SPACE; smlLibMemset(pAnchor, 0, sizeof(SmlMetInfAnchor_t)); if (IS_EMPTY(pScanner->curtok)) { *ppElem = pAnchor; return SML_ERR_OK; } if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) { smlFreeMetinfAnchor(pAnchor); //smlLibFree(pAnchor); return rc; } while (pScanner->curtok->type != TOK_TAG_END) { switch (pScanner->curtok->tagid) { /* PCDATA elements */ case TN_METINF_LAST: rc = buildPCData(pDecoder, (VoidPtr_t)&pAnchor->last); break; case TN_METINF_NEXT: rc = buildPCData(pDecoder, (VoidPtr_t)&pAnchor->next); break; default: rc = SML_ERR_XLT_INVAL_SYNCML_DOC; } if (rc != SML_ERR_OK) { smlFreeMetinfAnchor(pAnchor); //smlLibFree(pAnchor); return rc; } if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) { smlFreeMetinfAnchor(pAnchor); //smlLibFree(pAnchor); return rc; } } *ppElem = pAnchor; return SML_ERR_OK; }
/** * FUNCTION: smlLibStrdup * * Duplicates the String "constStringP". * Returns a pointer to the new copy of "constStringP". * * IN: String_t constStringP string, which is duplicated * RETURN: String_t pointer to the new copy, * null, if no copy could be allocated */ SML_API String_t smlLibStrdup (const char *constStringP) { String_t _new_str; // allocate memory for new copy _new_str = (String_t)smlLibMalloc(smlLibStrlen(constStringP) + 1); // Copy the string into the new memory if (_new_str != NULL) smlLibStrcpy(_new_str, constStringP); return _new_str; }