• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ OICCalloc函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中OICCalloc函数的典型用法代码示例。如果您正苦于以下问题:C++ OICCalloc函数的具体用法?C++ OICCalloc怎么用?C++ OICCalloc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了OICCalloc函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: OICCalloc

ProvisioningInfo *PrepareProvisioingStatusCB(OCClientResponse *clientResponse,
                                             ProvStatus provStatus) {

    ProvisioningInfo *provInfo = (ProvisioningInfo *) OICCalloc(1, sizeof(ProvisioningInfo));

    if (provInfo == NULL) {
        OIC_LOG_V(ERROR, TAG, "Failed to allocate memory");
        return NULL;
    }

    OCDevAddr *devAddr = (OCDevAddr *) OICCalloc(1, sizeof(OCDevAddr));

    if (devAddr == NULL) {
        OIC_LOG_V(ERROR, TAG, "Failed to allocate memory");
        return NULL;
    }

    strncpy(devAddr->addr, clientResponse->addr->addr, sizeof(devAddr->addr));
    devAddr->port = clientResponse->addr->port;

    provInfo->provDeviceInfo.addr = devAddr;

    provInfo->provStatus = provStatus;

    return provInfo;
}
开发者ID:tienfuc,项目名称:iotivity-democlient-snap,代码行数:26,代码来源:provisioning.cpp


示例2: CATimeoutCallback

static void CATimeoutCallback(const CAEndpoint_t *endpoint, const void *pdu, uint32_t size)
{
    OIC_LOG(DEBUG, TAG, "IN");
    VERIFY_NON_NULL_VOID(endpoint, TAG, "endpoint");
    VERIFY_NON_NULL_VOID(pdu, TAG, "pdu");

    CAEndpoint_t* ep = CACloneEndpoint(endpoint);
    if (!ep)
    {
        OIC_LOG(ERROR, TAG, "clone failed");
        return;
    }

    CAResponseInfo_t* resInfo = (CAResponseInfo_t*)OICCalloc(1, sizeof(CAResponseInfo_t));

    if (!resInfo)
    {
        OIC_LOG(ERROR, TAG, "calloc failed");
        CAFreeEndpoint(ep);
        return;
    }

    resInfo->result = CA_RETRANSMIT_TIMEOUT;
    resInfo->info.type = CAGetMessageTypeFromPduBinaryData(pdu, size);
    resInfo->info.messageId = CAGetMessageIdFromPduBinaryData(pdu, size);

    CAResult_t res = CAGetTokenFromPDU((const coap_hdr_t *) pdu, &(resInfo->info));
    if (CA_STATUS_OK != res)
    {
        OIC_LOG(ERROR, TAG, "fail to get Token from retransmission list");
        CADestroyResponseInfoInternal(resInfo);
        CAFreeEndpoint(ep);
        return;
    }

    CAData_t *cadata = (CAData_t *) OICCalloc(1, sizeof(CAData_t));
    if (NULL == cadata)
    {
        OIC_LOG(ERROR, TAG, "memory allocation failed !");
        CAFreeEndpoint(ep);
        CADestroyResponseInfoInternal(resInfo);
        return;
    }

    cadata->type = SEND_TYPE_UNICAST;
    cadata->remoteEndpoint = ep;
    cadata->requestInfo = NULL;
    cadata->responseInfo = resInfo;

#ifdef SINGLE_THREAD
    CAProcessReceivedData(cadata);
#else
    CAQueueingThreadAddData(&g_receiveThread, cadata, sizeof(CAData_t));
#endif

    OIC_LOG(DEBUG, TAG, "OUT");
}
开发者ID:HoTaeWang,项目名称:iotivity,代码行数:57,代码来源:camessagehandler.c


示例3: FindStringLLInMap

static CborError FindStringLLInMap(const CborValue *linksMap, char *tag, OCStringLL **links)
{
    size_t len;
    CborError cborFindResult;
    CborValue rtArray;
    cborFindResult = cbor_value_map_find_value(linksMap, tag, &rtArray);
    if (CborNoError != cborFindResult)
    {
        return CborUnknownError;
    }
    CborValue rtVal;
    cborFindResult = cbor_value_enter_container(&rtArray, &rtVal);
    if (CborNoError != cborFindResult)
    {
        return CborUnknownError;
    }
    OCStringLL* llPtr = *links;
    while (cbor_value_is_text_string(&rtVal))
    {
        if (llPtr == NULL)
        {
            llPtr = (OCStringLL *)OICCalloc(1, sizeof(OCStringLL));
            if (!llPtr)
            {
                return CborUnknownError;
            }
            *links = llPtr;
        }
        else if(llPtr)
        {
            while (llPtr->next)
            {
                llPtr = llPtr->next;
            }
            llPtr->next = (OCStringLL *)OICCalloc(1, sizeof(OCStringLL));
            if (!llPtr->next)
            {
                return CborUnknownError;
            }
        }
        cborFindResult = cbor_value_dup_text_string(&rtVal, &(llPtr->value), &len, NULL);
        if (CborNoError != cborFindResult)
        {
            return CborUnknownError;
        }
        cborFindResult = cbor_value_advance(&rtVal);
        if (CborNoError != cborFindResult)
        {
            return CborUnknownError;
        }
    }

    cborFindResult = cbor_value_leave_container(&rtArray, &rtVal);
    return cborFindResult;
}
开发者ID:TianyouLi,项目名称:iotivity,代码行数:55,代码来源:rdpayload.c


示例4: SetPlatformInfo

OCStackResult SetPlatformInfo()
{
    static const OCPlatformInfo platformInfo =
        {
            .platformID = "IoTivityZigbeeID",
            .manufacturerName = "IoTivity",
            .manufacturerUrl = "http://iotivity.org",
            .modelNumber = "T1000",
            .dateOfManufacture = "January 14th, 2015",
            .platformVersion = "0.9.2",
            .operatingSystemVersion = "7",
            .hardwareVersion = "0.5",
            .firmwareVersion = "0",
            .supportUrl = "http://iotivity.org",
            .systemTime = ""
        };

    return OCSetPlatformInfo(platformInfo);
}

OCStackResult SetDeviceInfo()
{
    static OCDeviceInfo deviceInfo =
        {
            .deviceName = "IoTivity/Zigbee Server Sample",
            .specVersion = "IoTivity/Zigbee Device Spec Version",
        };
    char *dmv = OICStrdup("IoTivity/Zigbee Data Model Version");
    deviceInfo.dataModelVersions = (OCStringLL *)OICCalloc(1, sizeof(OCStringLL));
    deviceInfo.dataModelVersions->value = dmv;
    char *dup = OICStrdup("oic.wk.d");
    deviceInfo.types = (OCStringLL *)OICCalloc(1, sizeof(OCStringLL));
    deviceInfo.types->value = dup;
    return OCSetDeviceInfo(deviceInfo);
}

bool processSignal(bool set)
{
    static sig_atomic_t signal = 0;
    if (set)
    {
        signal = 1;
    }

    return signal == 1;
}

void processCancel(int signal)
{
    if(signal == SIGINT)
    {
        processSignal(true);
    }
}
开发者ID:Subh1994,项目名称:iotivity,代码行数:54,代码来源:IotivityandZigbeeServer.c


示例5: createPdAcl

static OicSecPdAcl_t* createPdAcl(const int dev_num)
{
    if(0>=dev_num || g_own_cnt<dev_num)
    {
        OIC_LOG(ERROR, TAG, "createAcl invalid parameters");
        return NULL;  // not need to 'goto' |ERROR| before allocating |acl|
    }

    // allocate memory for |pdacl| struct
    printf("   **** Create PDACL for the Selected Device[%d]\n", dev_num);
    OicSecPdAcl_t* pdAcl = (OicSecPdAcl_t*) OICCalloc(1, sizeof(OicSecPdAcl_t));
    if(!pdAcl)
    {
        OIC_LOG(ERROR, TAG, "createAcl: OICCalloc error return");
        return NULL;  // not need to 'goto' |ERROR| before allocating |acl|
    }


    // number of resources
    char rsrc_in[][ACL_RESRC_MAX_LEN+1] = {"*", "/rsrc/*"};
    pdAcl->resourcesLen = 1;

    // resource
    int num = pdAcl->resourcesLen;
    pdAcl->resources = (char**) OICCalloc(num, sizeof(char*));
    if(!pdAcl->resources)
    {
        OIC_LOG(ERROR, TAG, "createPdAcl: OICCalloc error return");
        goto CRPDACL_ERROR;
    }
    for(int i=0; num>i; ++i)
    {
        size_t len = strlen(rsrc_in[i])+1;  // '1' for null termination
        char* rsrc = (char*) OICCalloc(len, sizeof(char));
        if(!rsrc)
        {
            OIC_LOG(ERROR, TAG, "createPdAcl: OICCalloc error return");
            goto CRPDACL_ERROR;
        }
        OICStrcpy(rsrc, len, rsrc_in[i]);
        pdAcl->resources[i] = rsrc;  // after here, |rsrc| points nothing
    }

    // permission
    pdAcl->permission = PERMISSION_FULL_CONTROL;

    return pdAcl;

CRPDACL_ERROR:
    OCDeletePdAclList(pdAcl);
    return NULL;
}
开发者ID:iotk,项目名称:iochibity-cxx,代码行数:52,代码来源:provisioningclient.c


示例6: OCStringLLJoin

static char* OCStringLLJoin(OCStringLL* val)
{
    OCStringLL* temp = val;
    size_t size = strlen(temp->value);

    while (temp->next)
    {
        ++size;
        temp = temp->next;
        size += strlen(temp->value);
    }

    char* joinedStr = (char*)OICCalloc(sizeof(char), size + 1);

    if (!joinedStr)
    {
        return NULL;
    }

    OICStrcat(joinedStr, size + 1, val->value);
    while (val->next)
    {
        val = val->next;
        OICStrcat(joinedStr, size + 1, " ");
        OICStrcat(joinedStr, size + 1, val->value);
    }
    return joinedStr;
}
开发者ID:hanglei,项目名称:iotivity,代码行数:28,代码来源:ocpayloadconvert.c


示例7: ConvertUuidToStr

OCStackResult ConvertUuidToStr(const OicUuid_t* uuid, char** strUuid)
{
    if(NULL == uuid || NULL == strUuid || NULL != *strUuid)
    {
        OIC_LOG(ERROR, TAG, "ConvertUuidToStr : Invalid param");
        return OC_STACK_INVALID_PARAM;
    }

    size_t uuidIdx = 0;
    size_t urnIdx = 0;
    const size_t urnBufSize = (UUID_LENGTH * 2) + 4 + 1;
    char* convertedUrn = (char*)OICCalloc(urnBufSize, sizeof(char));
    VERIFY_NON_NULL(TAG, convertedUrn, ERROR);

    for(uuidIdx=0, urnIdx=0;  uuidIdx < UUID_LENGTH && urnIdx < urnBufSize; uuidIdx++, urnIdx+=2)
    {
        // canonical format for UUID has '8-4-4-4-12'
        if(uuidIdx==4 || uuidIdx==6 || uuidIdx==8 || uuidIdx==10)
        {
            snprintf(convertedUrn + urnIdx, 2, "%c", '-');
            urnIdx++;
        }
        snprintf(convertedUrn + urnIdx, 3, "%02x", (uint8_t)(uuid->id[uuidIdx]));
    }
    convertedUrn[urnBufSize - 1] = '\0';

    *strUuid = convertedUrn;
    return OC_STACK_OK;

exit:
    return OC_STACK_NO_MEMORY;
}
开发者ID:Frank-KunLi,项目名称:iotivity,代码行数:32,代码来源:srmutility.c


示例8: CATimeoutCallback

static void CATimeoutCallback(const CAEndpoint_t *endpoint, const void *pdu, uint32_t size)
{
    OIC_LOG(DEBUG, TAG, "IN");
    CAEndpoint_t* ep = CACloneEndpoint(endpoint);
    if (NULL == ep)
    {
        OIC_LOG(ERROR, TAG, "clone failed");
        return;
    }

    CAResponseInfo_t* resInfo = (CAResponseInfo_t*) OICCalloc(1, sizeof(CAResponseInfo_t));

    if (NULL == resInfo)
    {
        OIC_LOG(ERROR, TAG, "calloc failed");
        CAFreeEndpoint(ep);
        return;
    }

    resInfo->result = CA_RETRANSMIT_TIMEOUT;
    resInfo->info.type = CAGetMessageTypeFromPduBinaryData(pdu, size);
    resInfo->info.messageId = CAGetMessageIdFromPduBinaryData(pdu, size);

    if (g_responseHandler)
    {
        g_responseHandler(ep, resInfo);
    }

    CAFreeEndpoint(ep);
    OICFree(resInfo);

    OIC_LOG(DEBUG, TAG, "OUT");
}
开发者ID:darcyg,项目名称:iotivity-1,代码行数:33,代码来源:camessagehandler_singlethread.c


示例9: CADetachResponseMessage

CAResult_t CADetachResponseMessage(const CAEndpoint_t *object,
                                   const CAResponseInfo_t *response)
{
    OIC_LOG(DEBUG, TAG, "IN");
    VERIFY_NON_NULL(object, TAG, "object");
    VERIFY_NON_NULL(response, TAG, "response");

    // allocate & initialize
    CAData_t *data = (CAData_t *) OICCalloc(1, sizeof(CAData_t));
    CA_MEMORY_ALLOC_CHECK(data);

    // save data
    data->type = SEND_TYPE_UNICAST;
    data->remoteEndpoint = object;
    data->requestInfo = NULL;
    data->responseInfo = response;

    CAProcessData(data);

    OICFree(data);
    OIC_LOG(DEBUG, TAG, "OUT");
    return CA_STATUS_OK;

// memory error label.
memory_error_exit:
    OICFree(data);
    OIC_LOG(DEBUG, TAG, "OUT");

    return CA_MEMORY_ALLOC_FAILED;
}
开发者ID:darcyg,项目名称:iotivity-1,代码行数:30,代码来源:camessagehandler_singlethread.c


示例10: CADetachRequestMessage

CAResult_t CADetachRequestMessage(const CAEndpoint_t *object, const CARequestInfo_t *request)
{
    OIC_LOG(DEBUG, TAG, "IN");

    VERIFY_NON_NULL(object, TAG, "object");
    VERIFY_NON_NULL(request, TAG, "request");

    // If max retransmission queue is reached, then don't handle new request
    if (CA_MAX_RT_ARRAY_SIZE == u_arraylist_length(g_retransmissionContext.dataList))
    {
        OIC_LOG(ERROR, TAG, "max RT queue size reached!");
        return CA_SEND_FAILED;
    }

    // allocate & initialize
    CAData_t *data = (CAData_t *) OICCalloc(1, sizeof(CAData_t));
    CA_MEMORY_ALLOC_CHECK(data);

    // save data
    data->type = request->isMulticast ? SEND_TYPE_MULTICAST : SEND_TYPE_UNICAST;
    data->remoteEndpoint = object;
    data->requestInfo = request;
    data->responseInfo = NULL;

    CAProcessData(data);
    OICFree(data);
    OIC_LOG(DEBUG, TAG, "OUT");
    return CA_STATUS_OK;

// memory error label.
memory_error_exit:
    OICFree(data);
    OIC_LOG(DEBUG, TAG, "OUT");
    return CA_MEMORY_ALLOC_FAILED;
}
开发者ID:darcyg,项目名称:iotivity-1,代码行数:35,代码来源:camessagehandler_singlethread.c


示例11: VERIFY_NON_NULL_RET

CATCPData *CACreateTCPData(const CAEndpoint_t *remoteEndpoint, const void *data,
                           size_t dataLength, bool isMulticast)
{
    VERIFY_NON_NULL_RET(remoteEndpoint, TAG, "remoteEndpoint is NULL", NULL);
    VERIFY_NON_NULL_RET(data, TAG, "data is NULL", NULL);

    CATCPData *tcpData = (CATCPData *) OICCalloc(1, sizeof(*tcpData));
    if (!tcpData)
    {
        OIC_LOG(ERROR, TAG, "Memory allocation failed!");
        return NULL;
    }

    tcpData->remoteEndpoint = CACloneEndpoint(remoteEndpoint);
    tcpData->data = (void *) OICMalloc(dataLength);
    if (!tcpData->data)
    {
        OIC_LOG(ERROR, TAG, "Memory allocation failed!");
        CAFreeTCPData(tcpData);
        return NULL;
    }

    memcpy(tcpData->data, data, dataLength);
    tcpData->dataLen = dataLength;

    tcpData->isMulticast = isMulticast;

    return tcpData;
}
开发者ID:Dosercyan,项目名称:iotivity,代码行数:29,代码来源:catcpadapter.c


示例12: TEST

TEST(MarshalingAndUnMarshalingTest, BinToPstatJSONAndJSONToPstatBin)
{
    const char* id = "ZGV2aWNlaWQAAAAAABhanw==";
    OicSecPstat_t pstat;
    pstat.cm = NORMAL;
    pstat.commitHash = 0;
    uint32_t outLen = 0;
    unsigned char base64Buff[sizeof(((OicUuid_t*) 0)->id)] = {};
    EXPECT_EQ(B64_OK, b64Decode(id, strlen(id), base64Buff, sizeof(base64Buff), &outLen));
    memcpy(pstat.deviceID.id, base64Buff, outLen);
    pstat.isOp = true;
    pstat.tm = NORMAL;
    pstat.om = SINGLE_SERVICE_CLIENT_DRIVEN;
    pstat.smLen = 2;
    pstat.sm = (OicSecDpom_t*)OICCalloc(pstat.smLen, sizeof(OicSecDpom_t));
    pstat.sm[0] = SINGLE_SERVICE_CLIENT_DRIVEN;
    pstat.sm[1] = SINGLE_SERVICE_SERVER_DRIVEN;
    char* jsonPstat = BinToPstatJSON(&pstat);
    printf("BinToJSON Dump:\n%s\n\n", jsonPstat);
    EXPECT_TRUE(jsonPstat != NULL);
    OicSecPstat_t *pstat1 = JSONToPstatBin(jsonPstat);
    EXPECT_TRUE(pstat1 != NULL);
    OICFree(pstat1->sm);
    OICFree(pstat1);
    OICFree(jsonPstat);
    OICFree(pstat.sm);
}
开发者ID:darcyg,项目名称:iotivity-1,代码行数:27,代码来源:pstatresource.cpp


示例13: CAReceiveMessage

static void CAReceiveMessage(int fd)
{
    // #1. get remote device information from file descriptor.
    size_t index = 0;
    CATCPSessionInfo_t *svritem = CAGetSessionInfoFromFD(fd, &index);
    if (!svritem)
    {
        OIC_LOG(ERROR, TAG, "there is no connection information in list");
        return;
    }

    // #2. get already allocated memory size.
    size_t bufSize = (svritem->totalDataLen == 0) ? TCP_MAX_HEADER_LEN : svritem->totalDataLen;
    if (!svritem->recvData)
    {
        svritem->recvData = (unsigned char *) OICCalloc(1, bufSize);
        if (!svritem->recvData)
        {
            OIC_LOG(ERROR, TAG, "out of memory");
            CADisconnectTCPSession(svritem, index);
            return;
        }
    }

    // #3. receive data from remote device.
    ssize_t recvLen = recv(fd, svritem->recvData + svritem->recvDataLen,
                           bufSize - svritem->recvDataLen, 0);
    if (recvLen <= 0)
    {
        if(EWOULDBLOCK != errno)
        {
            OIC_LOG_V(ERROR, TAG, "Recvfrom failed %s", strerror(errno));
            CADisconnectTCPSession(svritem, index);
        }
        return;
    }
    svritem->recvDataLen += recvLen;

    // #4. get actual data length from coap over tcp header.
    if (!svritem->totalDataLen)
    {
        coap_transport_type transport = coap_get_tcp_header_type_from_initbyte(
                ((unsigned char *) svritem->recvData)[0] >> 4);

        size_t headerLen = coap_get_tcp_header_length_for_transport(transport);
        if (svritem->recvDataLen >= headerLen)
        {
            svritem->totalDataLen = CAGetTotalLengthFromHeader(
                    (unsigned char *) svritem->recvData);
            bufSize = svritem->totalDataLen;
            unsigned char *newBuf = OICRealloc(svritem->recvData, bufSize);
            if (!newBuf)
            {
                OIC_LOG(ERROR, TAG, "out of memory");
                CADisconnectTCPSession(svritem, index);
                return;
            }
            svritem->recvData = newBuf;
        }
    }
开发者ID:rajesh89s,项目名称:iotivity,代码行数:60,代码来源:catcpserver.c


示例14: getDoubleValueFromString

OCEntityHandlerResult getDoubleValueFromString (const char *str, double *outDouble)
{
    size_t hexOutValSize = strlen(HexPrepend) + strlen(str) + 1;
    char * hexOutVal = (char *) OICCalloc(1, hexOutValSize);
    if(!hexOutVal)
    {
        return OC_EH_ERROR;
    }
    OICStrcpy(hexOutVal, hexOutValSize, HexPrepend);
    OICStrcat(hexOutVal, hexOutValSize, str);

    char *endPtr = NULL;
    errno = 0;
    double value = strtod(hexOutVal, &endPtr);

    if(errno != 0 || *endPtr != 0 || value == HUGE_VALF || value == HUGE_VALL)
    {
        OICFree(hexOutVal);
        return OC_EH_ERROR;
    }

    OICFree(hexOutVal);
    *outDouble = value;
    return OC_EH_OK;

}
开发者ID:TianyouLi,项目名称:iotivity,代码行数:26,代码来源:zigbee_wrapper.c


示例15: appendStringLL

static OCStackResult appendStringLL(OCStringLL **type, const unsigned char *value)
{
    OCStringLL *temp= (OCStringLL*)OICCalloc(1, sizeof(OCStringLL));
    if (!temp)
    {
        return OC_STACK_NO_MEMORY;
    }
    temp->value = OICStrdup((char *)value);
    if (!temp->value)
    {
        return OC_STACK_NO_MEMORY;
    }
    temp->next = NULL;

    if (!*type)
    {
        *type = temp;
    }
    else
    {
        OCStringLL *tmp = *type;
        for (; tmp->next; tmp = tmp->next);
        tmp->next = temp;
    }
    return OC_STACK_OK;
}
开发者ID:drashti304,项目名称:TizenRT,代码行数:26,代码来源:oicresourcedirectory.c


示例16: sizeof

OCRDDiscoveryPayload *OCRDDiscoveryPayloadCreate(const char *deviceName, const char *id, int biasFactor)
{
    OCRDDiscoveryPayload *discoveryPayload = (OCRDDiscoveryPayload *)OICCalloc(1, sizeof(OCRDDiscoveryPayload));

    if (!discoveryPayload)
    {
        return NULL;
    }

    if (deviceName)
    {
        discoveryPayload->n.deviceName = OICStrdup(deviceName);
        if (!discoveryPayload->n.deviceName)
        {
            OICFree(discoveryPayload);
            return NULL;
        }
    }
    if (id)
    {
        OICStrcpy((char*)discoveryPayload->di.id, MAX_IDENTITY_SIZE, id);
    }

    discoveryPayload->sel = biasFactor;

    return discoveryPayload;
}
开发者ID:TianyouLi,项目名称:iotivity,代码行数:27,代码来源:rdpayload.c


示例17: OCTagsCborToPayload

static CborError OCTagsCborToPayload(CborValue *tagsMap, OCTagsPayload **tagsPayload)
{
    CborError cborFindResult = CborErrorOutOfMemory;
    OCTagsPayload *tags = (OCTagsPayload *)OICCalloc(1, sizeof(OCTagsPayload));
    VERIFY_PARAM_NON_NULL(TAG, tags, "Failed allocating tags");

    cborFindResult = FindStringInMap(tagsMap, OC_RSRVD_DEVICE_NAME, &tags->n.deviceName);
    VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed finding deviceName");

    {
        char *deviceId = NULL;
        cborFindResult = FindStringInMap(tagsMap, OC_RSRVD_DEVICE_ID, &deviceId);
        if (deviceId)
        {
            memcpy(tags->di.id, deviceId, strlen(deviceId));
            OICFree(deviceId);
        }
        VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed finding deviceId");
    }

    cborFindResult = FindIntInMap(tagsMap, OC_RSRVD_DEVICE_TTL, &tags->ttl);
    VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed finding ttl");

    *tagsPayload = tags;
    return cborFindResult;

exit:
    OCFreeTagsResource(tags);
    return cborFindResult;
}
开发者ID:alexgg,项目名称:iotivity,代码行数:30,代码来源:rdpayload.c


示例18: OCCopyTagsResources

OCTagsPayload* OCCopyTagsResources(const char *deviceName, const unsigned char *id, uint64_t ttl)
{
    OCTagsPayload *tags = (OCTagsPayload *)OICCalloc(1, sizeof(OCTagsPayload));
    if (!tags)
    {
        return NULL;
    }
    if (deviceName)
    {
        tags->n.deviceName = OICStrdup(deviceName);
        if (!tags->n.deviceName)
        {
            goto memory_allocation_failed;
        }
    }
    if (id)
    {
        OICStrcpy((char*)tags->di.id, MAX_IDENTITY_SIZE, (char *)id);
    }
    tags->ttl = ttl;
    return tags;

memory_allocation_failed:
    OIC_LOG(ERROR, TAG, "Memory allocation failed.");
    OCFreeTagsResource(tags);
    return NULL;
}
开发者ID:alexgg,项目名称:iotivity,代码行数:27,代码来源:rdpayload.c


示例19: PDMGetOwnedDevices

OCStackResult PDMGetOwnedDevices(OCUuidList_t **uuidList, size_t *numOfDevices)
{
    CHECK_PDM_INIT(TAG);
    if (NULL != *uuidList)
    {
        OC_LOG(ERROR, TAG, "Not null list will cause memory leak");
        return OC_STACK_INVALID_PARAM;
    }
    sqlite3_stmt *stmt = 0;
    int res = 0;
    res = sqlite3_prepare_v2(g_db, PDM_SQLITE_LIST_ALL_UUID,
                              strlen(PDM_SQLITE_LIST_ALL_UUID) + 1, &stmt, NULL);
    PDM_VERIFY_SQLITE_OK(TAG, res, ERROR, OC_STACK_ERROR);

    int counter  = 0;
    while (SQLITE_ROW == sqlite3_step(stmt))
    {

        const void *ptr = sqlite3_column_blob(stmt, PDM_FIRST_INDEX);
        OicUuid_t *uid = (OicUuid_t *)ptr;
        OCUuidList_t *temp = (OCUuidList_t *) OICCalloc(1,sizeof(OCUuidList_t));
        if (NULL == temp)
        {
            OC_LOG_V(ERROR, TAG, "Memory allocation problem");
            sqlite3_finalize(stmt);
            return OC_STACK_NO_MEMORY;
        }
        memcpy(&temp->dev.id, uid->id, UUID_LENGTH);
        LL_PREPEND(*uuidList,temp);
        ++counter;
    }
    *numOfDevices = counter;
    sqlite3_finalize(stmt);
    return OC_STACK_OK;
}
开发者ID:rzr,项目名称:iotivity-1,代码行数:35,代码来源:provisioningdatabasemanager.c


示例20: UpdateAmsMgrContext

OCStackResult UpdateAmsMgrContext(PEContext_t *context, const CAEndpoint_t *endpoint,
                        const CARequestInfo_t *requestInfo)
{
    OCStackResult ret = OC_STACK_ERROR;

    //The AmsMgr context endpoint and requestInfo will be free from ,
    //AmsMgrAclReqCallback function
    if(context->amsMgrContext->endpoint)
    {
        OICFree(context->amsMgrContext->endpoint);
        context->amsMgrContext->endpoint = NULL;
    }
    context->amsMgrContext->endpoint = (CAEndpoint_t *)OICCalloc(1, sizeof(CAEndpoint_t ));
    VERIFY_NON_NULL(TAG, context->amsMgrContext->endpoint, ERROR);
    *context->amsMgrContext->endpoint = *endpoint;

    if(context->amsMgrContext->requestInfo)
    {
        FreeCARequestInfo(context->amsMgrContext->requestInfo);
        context->amsMgrContext->requestInfo = NULL;
    }
    context->amsMgrContext->requestInfo = CACloneRequestInfo(requestInfo);
    VERIFY_NON_NULL(TAG, context->amsMgrContext->requestInfo, ERROR);
    ret = OC_STACK_OK;
exit:
    return ret;
}
开发者ID:keyfour,项目名称:iotivity,代码行数:27,代码来源:amsmgr.c



注:本文中的OICCalloc函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ OICFree函数代码示例发布时间:2022-05-30
下一篇:
C++ OH_GET_REFERENCE函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap