OCLinksPayload* OCCopyLinksResources(const char *href, OCStringLL *rt, OCStringLL *itf, const char *rel, bool obs, const char *title, const char *uri, uint8_t ins, OCStringLL *mt) { OCLinksPayload *links = (OCLinksPayload *)OICCalloc(1, sizeof(OCLinksPayload)); if (!links) { OC_LOG(ERROR, TAG, "Failed allocating memory."); return NULL; } if (href) { links->href = OICStrdup(href); if (!links->href) { goto memory_allocation_failed; } } if (rt) { links->rt = CloneOCStringLL(rt); if (!links->rt) { goto memory_allocation_failed; } } if (itf) { links->itf = CloneOCStringLL(itf); if (!links->itf) { goto memory_allocation_failed; } } if (rel) { links->rel = OICStrdup(rel); if (!links->rel) { goto memory_allocation_failed; } } links->obs = obs; if (title) { links->title = OICStrdup(title); if (!links->title) { goto memory_allocation_failed; } } if (uri) { links->uri = OICStrdup(uri); if (!links->uri) { goto memory_allocation_failed; } } links->ins = ins; if (mt) { links->mt = CloneOCStringLL(mt); if (!links->mt) { goto memory_allocation_failed; } } links->next = NULL; return links; memory_allocation_failed: OC_LOG(ERROR, TAG, "Memory allocation failed."); OCFreeLinksResource(links); return NULL; }
OCLinksPayload* OCCopyLinksResources(const char *href, const char *rel, OCStringLL *rt, OCStringLL *itf, uint8_t p, const char *title, const char *anchor, uint8_t ins, uint64_t ttl, OCStringLL *mt) { OCLinksPayload *links = (OCLinksPayload *)OICCalloc(1, sizeof(OCLinksPayload)); if (!links) { OIC_LOG(ERROR, TAG, "Failed allocating memory."); return NULL; } if (href) { links->href = OICStrdup(href); if (!links->href) { goto memory_allocation_failed; } } if (rel) { links->rel = OICStrdup(rel); if (!links->rel) { goto memory_allocation_failed; } } if (rt) { links->rt = CloneOCStringLL(rt); if (!links->rt) { goto memory_allocation_failed; } } if (itf) { links->itf = CloneOCStringLL(itf); if (!links->itf) { goto memory_allocation_failed; } } links->p = p; if (title) { links->title = OICStrdup(title); if (!links->title) { goto memory_allocation_failed; } } if (anchor) { links->anchor = OICStrdup(anchor); if (!links->anchor) { goto memory_allocation_failed; } } links->ins = ins; links->ttl = ttl; if (mt) { links->type = CloneOCStringLL(mt); if (!links->type) { goto memory_allocation_failed; } } links->next = NULL; return links; memory_allocation_failed: OIC_LOG(ERROR, TAG, "Memory allocation failed."); OCFreeLinksResource(links); return NULL; }