当前位置: 首页>>代码示例>>C++>>正文


C++ osal_mem_free函数代码示例

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


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

示例1: gateway_to_pda

void gateway_to_pda(uint16 shortaddr, uint8*buf, uint8 len)// 这儿的buf也 是一完整的协议data
{
   uint8*mbuf;
   uint8 i;
   mbuf = osal_mem_alloc( (len+4)*sizeof(uint8));
   
   mbuf[0] = len+3;
   mbuf[1] = 0x08;
   
   mbuf[2] = HI_UINT16(shortaddr);
   mbuf[3] = LO_UINT16(shortaddr);
   
   for( i = 0; i < len; i++)
   {
     mbuf[i+4] = buf[i];
   }
   
   // uart to send
   if( HalUARTWrite(0,mbuf, len+4) > 0)
   {
     osal_mem_free(mbuf);
   }else
   {
     HalUARTWrite(SER_PORT,mbuf, len+4);
     osal_mem_free(mbuf);
   }
   
   return;
}
开发者ID:cuu,项目名称:weiyi,代码行数:29,代码来源:protocol.c

示例2: deleteSignalStrength

//*********************************************
static void deleteSignalStrength( uint8 modbus_id)
{
  signalStrength_t *pLoop, *pNext;
  
  pLoop = pSignalStren;
  pNext = pSignalStren->next;
  
  if( pLoop != NULL)
  {
    if(pLoop->modbus_id == modbus_id)
    {
      numSignalStren--;
      if(pNext != NULL)
        pSignalStren = pNext;
      else
        pSignalStren = NULL;
      osal_mem_free( pLoop);
    }
    else
    {
      while( pNext != NULL)
      {
        if(pNext->modbus_id == modbus_id)
        {
          numSignalStren--;
          pLoop->next = pNext->next;
          osal_mem_free(pNext);
          return;
        }
        pLoop = pNext;
        pNext = pLoop->next;
      }
    }
  }
}
开发者ID:temcocontrols,项目名称:Zigbee-Tstat8-T3-controllers,代码行数:36,代码来源:temcoAPI.c

示例3: rbuf_destroy

int rbuf_destroy(ringbuffer_t *rb)
{
    if (!rb || !(rb->buffer))
      return -1;
    
    osal_mem_free(rb->buffer);
    osal_mem_free(rb);
    return 0;
}
开发者ID:jtuki,项目名称:sakuc,代码行数:9,代码来源:ringbuffer.c

示例4: Glucose_AddService

/*********************************************************************
 * @fn      Glucose_AddService
 *
 * @brief   Initializes the Glucose   service by registering
 *          GATT attributes with the GATT server.
 *
 * @param   services - services to add. This is a bit map and can
 *                     contain more than one service.
 *
 * @return  Success or Failure
 */
bStatus_t Glucose_AddService(uint32 services)
{
    uint8 status;

    // Allocate Client Characteristic Configuration table
    glucoseMeasConfig = (gattCharCfg_t *)osal_mem_alloc( sizeof(gattCharCfg_t) *
                        linkDBNumConns );
    if ( glucoseMeasConfig == NULL )
    {
        return ( bleMemAllocError );
    }

    // Allocate Client Characteristic Configuration table
    glucoseContextConfig = (gattCharCfg_t *)osal_mem_alloc( sizeof(gattCharCfg_t) *
                           linkDBNumConns );
    if ( glucoseContextConfig == NULL )
    {
        // Free already allocated data
        osal_mem_free( glucoseMeasConfig );

        return ( bleMemAllocError );
    }

    // Allocate Client Characteristic Configuration table
    glucoseControlConfig = (gattCharCfg_t *)osal_mem_alloc( sizeof(gattCharCfg_t) *
                           linkDBNumConns );
    if ( glucoseControlConfig == NULL )
    {
        // Free already allocated data
        osal_mem_free( glucoseMeasConfig );
        osal_mem_free( glucoseContextConfig );

        return ( bleMemAllocError );
    }

    // Initialize Client Characteristic Configuration attributes.
    GATTServApp_InitCharCfg(INVALID_CONNHANDLE, glucoseMeasConfig);
    GATTServApp_InitCharCfg(INVALID_CONNHANDLE, glucoseContextConfig);
    GATTServApp_InitCharCfg(INVALID_CONNHANDLE, glucoseControlConfig);

    if (services & GLUCOSE_SERVICE)
    {
        // Register GATT attribute list and CBs with GATT Server App.
        status = GATTServApp_RegisterService(glucoseAttrTbl,
                                             GATT_NUM_ATTRS(glucoseAttrTbl),
                                             GATT_MAX_ENCRYPT_KEY_SIZE,
                                             &glucoseCBs);
    }
    else
    {
        status = SUCCESS;
    }

    return (status);
}
开发者ID:denjackson,项目名称:RemoteControl-Car,代码行数:66,代码来源:glucservice.c

示例5: HalUARTCloseIsr

/*************************************************************************************************
 * @fn      HalUARTCloseIsr()
 *
 * @brief   Close the UART
 *
 * @param   port - UART port (not used.)
 *
 * @return  none
 *************************************************************************************************/
void HalUARTCloseIsr(uint8 port)
{
  (void)port;

  UARTDisable(HAL_UART_PORT);

  if (uartRecord.configured)
  {
    (void)osal_mem_free(uartRecord.rx.pBuffer);
    (void)osal_mem_free(uartRecord.tx.pBuffer);
    recRst();
  }
}
开发者ID:ndksys01,项目名称:FinalProject,代码行数:22,代码来源:hal_uart_isr.c

示例6: NpiSerialCallback

/*
1, 思路:  当串口收到数据后,就会马上调用以下回调函数,在实际测试中发现,此回调
函数调用频繁, 如果你不执行NPI_ReadTransport函数进行读取, 那么这个回调函数就会
频繁地被执行,但是,你通过串口发送一段数据, 你本意是想处理这一完整一段的数据,所以,
我们在下面引入了时间的处理方法, 也即接收的数据够多或者超时,就读取一次数据, 
然后根据当前的状态决定执行,如果没有连接上,就把所有数据当做AT命令处理, 如果连接
上了,就把数据送到对端。  ---------------amomcu   2014.08.17
*/
void NpiSerialCallback( uint8 port, uint8 events )
{
    (void)port;//加个 (void),是未了避免编译告警,明确告诉缓冲区不用理会这个变量

    if (events & (HAL_UART_RX_TIMEOUT | HAL_UART_RX_FULL))   //串口有数据
    {
        uint8 numBytes = 0;

        numBytes = NPI_RxBufLen();           //读出串口缓冲区有多少字节
        
        if(numBytes == 0)
        {
            return;
        }
        else
        {
            //申请缓冲区buffer
            uint8 *buffer = osal_mem_alloc(numBytes);
            if(buffer)
            {
                //读取读取串口缓冲区数据,释放串口数据   
                NPI_ReadTransport(buffer,numBytes);   

                //把收到的数据发送到串口-实现回环 
                NPI_WriteTransport(buffer, numBytes);  

                //释放申请的缓冲区
                osal_mem_free(buffer);
            }
        }
    }
}
开发者ID:liu470895,项目名称:car_lock,代码行数:40,代码来源:app_uart.c

示例7: resetCharacteristicValue

/*********************************************************************
 * @fn      resetCharacteristicValue
 *
 * @brief   Initialize a characteristic value to zero
 *
 * @param   servID - service ID (UUID)
 *
 * @param   paramID - parameter ID of the value is to be cleared
 *
 * @param   vakue - value to initialise with
 *
 * @param   paramLen - length of the parameter
 *
 * @return  none
 */
static void resetCharacteristicValue(uint16 servUuid, uint8 paramID, uint8 value, uint8 paramLen)
{
    uint8* pData = osal_mem_alloc(paramLen);
    if (pData == NULL)
    {
        return;
    }
    osal_memset(pData,value,paramLen);
    switch(servUuid)
    {
            //case IRTEMPERATURE_SERV_UUID:
            //    IRTemp_SetParameter( paramID, paramLen, pData);
            //    break;
            case ACCELEROMETER_SERV_UUID:
                Accel_SetParameter( paramID, paramLen, pData);
                break;
            //case MAGNETOMETER_SERV_UUID:
            //    Magnetometer_SetParameter( paramID, paramLen, pData);
            //    break;
            //case HUMIDITY_SERV_UUID:
            //    Humidity_SetParameter( paramID, paramLen, pData);
            //    break;
            //case BAROMETER_SERV_UUID:
            //    Barometer_SetParameter( paramID, paramLen, pData);
            //    break;
        case GYROSCOPE_SERV_UUID:
            Gyro_SetParameter( paramID, paramLen, pData);
            break;
        default:
            // Should not get here
            break;
    }
    osal_mem_free(pData);
}
开发者ID:firechecking,项目名称:Hedwig-SixAxis-6050,代码行数:49,代码来源:SensorTag.c

示例8: nwk_MTCallbackSubJoinIndication

/***************************************************************************************************
 * @fn          nwk_MTCallbackSubJoinIndication
 *
 * @brief       Process the callback subscription for NLME-INIT-COORD.indication
 *
 * @param       ShortAddress - 16-bit address
 * @param       ExtendedAddress - IEEE (64-bit) address
 * @param       CapabilityFlags - Association Capability Information
 *
 * @return      ZStatus_t
 ***************************************************************************************************/
void nwk_MTCallbackSubJoinIndication( uint16 ShortAddress, uint8 *ExtendedAddress,
                                      uint8 CapabilityFlags )
{
  uint8 *msgPtr;
  uint8 *msg;
  uint8 len;

  len = sizeof( uint16 ) + Z_EXTADDR_LEN + sizeof( uint8 );
  msgPtr = osal_mem_alloc( len );

  if ( msgPtr )
  {
    /* Fill up the data bytes */
    msg = msgPtr;

    /* First fill in details */
    *msg++ = LO_UINT16( ShortAddress );
    *msg++ = HI_UINT16( ShortAddress );

    osal_cpyExtAddr( msg, ExtendedAddress );
    msg += Z_EXTADDR_LEN;

    *msg = CapabilityFlags;

    MT_BuildAndSendZToolResponse(((uint8)MT_RPC_CMD_AREQ | (uint8)MT_RPC_SYS_NWK), MT_NLME_JOIN_IND, len, msgPtr );

    osal_mem_free( msgPtr );
  }
}
开发者ID:paoloach,项目名称:zpowermeter,代码行数:40,代码来源:MT_NWK.c

示例9: nwk_MTCallbackSubDataIndication

/***************************************************************************************************
 * @fn          nwk_MTCallbackSubDataIndication
 *
 * @brief       Process the callback subscription for NLDE-DATA.indication
 *
 * @param       SrcAddress      - 16 bit address
 * @param       nsduLength      - Length of incoming data
 * @param       nsdu            - Pointer to incoming data
 * @param       LinkQuality     - Link quality measured during
 *                                reception.
 *
 * @return      none
 ***************************************************************************************************/
void nwk_MTCallbackSubDataIndication(uint16 SrcAddress, int16 nsduLength, uint8 *nsdu, uint8 LinkQuality)
{
  uint8 *msgPtr;
  uint8 *msg;
  uint8 msgLen;

  msgLen = sizeof( uint16 ) + sizeof( uint8 ) + ZTEST_DEFAULT_DATA_LEN
            + sizeof( uint8);

  msgPtr = osal_mem_alloc( msgLen );
  if ( msgPtr )
  {
    //Fill up the data bytes
    msg = msgPtr;

    //First fill in details
    *msg++ = LO_UINT16( SrcAddress );
    *msg++ = HI_UINT16( SrcAddress );

    //Since the max packet size is less than 255 bytes, a byte is enough
    //to represent nsdu length
    *msg++ = ( uint8 ) nsduLength;

    osal_memset( msg, NULL, ZTEST_DEFAULT_DATA_LEN ); // Clear the mem
    osal_memcpy( msg, nsdu, nsduLength );
    msg += ZTEST_DEFAULT_DATA_LEN;

    *msg++ = LinkQuality;

    MT_BuildAndSendZToolResponse( ((uint8)MT_RPC_CMD_AREQ | (uint8)MT_RPC_SYS_NWK), MT_NLDE_DATA_IND, msgLen, msgPtr );

    osal_mem_free( msgPtr );
  }
}
开发者ID:paoloach,项目名称:zpowermeter,代码行数:47,代码来源:MT_NWK.c

示例10: zclSS_Send_IAS_ACE_BypassCmd

/*********************************************************************
 * @fn      zclSS_Send_IAS_ACE_BypassCmd
 *
 * @brief   Call to send out a Bypass Command  ( IAS ACE Cluster )
 *
 * @param   srcEP - Sending application's endpoint
 * @param   dstAddr - where you want the message to go
 * @param   numberOfZones - one byte
 * @param   bypassBuf - zone IDs array of 256 entries one byte each
 *
 * @return  ZStatus_t
 */
ZStatus_t zclSS_Send_IAS_ACE_BypassCmd( uint8 srcEP, afAddrType_t *dstAddr,
                                        uint8 numberOfZones, uint8 *bypassBuf,
                                        uint8 disableDefaultRsp, uint8 seqNum )
{
    uint8 *buf;
    uint8 *pBuf;
    uint8 len = 1 + numberOfZones;
    ZStatus_t stat;

    buf = osal_mem_alloc( len );
    if ( buf )
    {
        pBuf = buf;

        *pBuf++ = numberOfZones;
        osal_memcpy( pBuf, bypassBuf, numberOfZones );

        stat = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SS_IAS_ACE,
                                COMMAND_SS_IAS_ACE_BYPASS, TRUE,
                                ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0, seqNum, len, buf );
        osal_mem_free( buf );
    }
    else
        stat = ZFailure;

    return ( stat );
}
开发者ID:FrankieChan885,项目名称:EndDevice-Project-for-editing,代码行数:39,代码来源:zcl_ss.c

示例11: zb_MTCallbackReceiveDataIndication

/***************************************************************************************************
 * @fn          zb_MTCallbackReceiveDataIndication
 *
 * @brief       Process the callback subscription for zb_ReceiveDataIndication
 *
 * @param
 *
 * @return      none
 ***************************************************************************************************/
void zb_MTCallbackReceiveDataIndication( uint16 source, uint16 command, uint16 len, uint8 *pData  )
{
  uint8 *memPtr;
  int8 i;
  uint8 msgLen = 6 + len;

  memPtr = osal_mem_alloc(msgLen);

  if (memPtr)
  {
    memPtr[0] = LO_UINT16(source);
    memPtr[1] = HI_UINT16(source);
    memPtr[2] = LO_UINT16(command);
    memPtr[3] = HI_UINT16(command);
    memPtr[4] = LO_UINT16(len);
    memPtr[5] = HI_UINT16(len);

    for (i=0; i<len; i++)
    {
      memPtr[6+i] = pData[i];
    }

    /* Build and send back the response */
    MT_BuildAndSendZToolResponse(((uint8)MT_RPC_CMD_AREQ | (uint8)MT_RPC_SYS_SAPI), MT_SAPI_RCV_DATA_IND, msgLen, memPtr);

    osal_mem_free( memPtr );
  }
}
开发者ID:paoloach,项目名称:zpowermeter,代码行数:37,代码来源:MT_SAPI.c

示例12: MT_AfRegister

/***************************************************************************************************
 * @fn      MT_AfRegister
 *
 * @brief   Process AF Register command
 *
 * @param   pBuf - pointer to the received buffer
 *
 * @return  none
 ***************************************************************************************************/
void MT_AfRegister(uint8 *pBuf)
{
  uint8 cmdId;
  uint8 retValue = ZMemError;
  endPointDesc_t *epDesc;

  /* parse header */
  cmdId = pBuf[MT_RPC_POS_CMD1];
  pBuf += MT_RPC_FRAME_HDR_SZ;

  epDesc = (endPointDesc_t *)osal_mem_alloc(sizeof(endPointDesc_t));
  if ( epDesc )
  {
    epDesc->task_id = &MT_TaskID;
    retValue = MT_BuildEndpointDesc( pBuf, epDesc );
    if ( retValue == ZSuccess )
    {
      retValue = afRegister( epDesc );
    }

    if ( retValue != ZSuccess )
    {
      osal_mem_free( epDesc );
    }
  }

  /* Build and send back the response */
  MT_BuildAndSendZToolResponse(((uint8)MT_RPC_CMD_SRSP | (uint8)MT_RPC_SYS_AF), cmdId, 1, &retValue);
}
开发者ID:chessami92,项目名称:ceen4360-cc2538-code,代码行数:38,代码来源:MT_AF.c

示例13: osal_bm_free

/*********************************************************************
 * @fn      osal_bm_free
 *
 * @brief   Implementation of the de-allocator functionality.
 *
 * @param   payload_ptr - pointer to the memory to free.
 *
 * @return  none
 */
void osal_bm_free( void *payload_ptr )
{
  bm_desc_t *loop_ptr;
  bm_desc_t *prev_ptr = NULL;
  
  loop_ptr = bm_list_ptr;
  while ( loop_ptr != NULL )
  {
    if ( payload_ptr >= (void *)START_PTR( loop_ptr ) &&
         payload_ptr <= (void *)END_PTR( loop_ptr) )
    {
      // unlink item from the linked list
      if ( prev_ptr == NULL )
      {
        // it's the first item on the list
        bm_list_ptr = loop_ptr->next_ptr;
      }
      else
      {
        prev_ptr->next_ptr = loop_ptr->next_ptr;
      }

      // free the memory
      osal_mem_free( loop_ptr );

      // we're done here
      break;
    }
    
    // move on to next item
    prev_ptr = loop_ptr;
    loop_ptr = loop_ptr->next_ptr;
  }
}
开发者ID:AubrCool,项目名称:BLE,代码行数:43,代码来源:osal_bufmgr.c

示例14: zclPI_Send_11073TransferAPDUCmd

/*******************************************************************************
 * @fn      zclPI_Send_11073TransferAPDUCmd
 *
 * @brief   Call to send out an 11073 Transfer APDU Command. This command is 
 *          used when an 11073 network layer wishes to transfer an 11073 APDU 
 *          across a ZigBee tunnel to another 11073 network layer.
 *
 *          The most stringent reliability characteristic of a given transport
 *          technology is “Best” reliability. Note - For ZigBee, this corresponds
 *          to use of APS-ACKs.
 *
 *          The least stringent reliability characteristic of a given transport
 *          technology is “Good” reliability. Note - For ZigBee, this corresponds
 *          to no use of APS-ACKs.
 *
 *          Note: This command shall always be transmitted with the Disable Default 
 *          Response bit in the ZCL frame control field set to 1.
 *
 * @param   srcEP - Sending application's endpoint
 * @param   dstAddr - where you want the message to go
 * @param   len - length of APDU
 * @param   apdu - APDU to be sent
 * @param   seqNum - sequence number
 *
 * @return  ZStatus_t
 */
ZStatus_t zclPI_Send_11073TransferAPDUCmd( uint8 srcEP, afAddrType_t *dstAddr,
                                           uint16 len, uint8 *apdu, uint8 seqNum )
{
  uint8 *buf;
  ZStatus_t stat;

  buf = osal_mem_alloc( len+2 ); // 2 for length field (long octet string)
  if ( buf )
  {  
    buf[0] = LO_UINT16( len );
    buf[1] = HI_UINT16( len );
    osal_memcpy( &(buf[2]), apdu, len );

    // This command shall always be transmitted with the Disable Default 
    // Response bit in the ZCL frame control field set to 1.
    stat = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_PI_11073_PROTOCOL_TUNNEL,
                            COMMAND_PI_11073_TUNNEL_TRANSFER_APDU, TRUE, 
                            ZCL_FRAME_CLIENT_SERVER_DIR, TRUE, 0, seqNum, (len+2), buf );
    osal_mem_free( buf );
  }
  else
  {
    stat = ZMemError;
  }
  
  return ( stat );
}
开发者ID:binwulang,项目名称:zstack-agriculture,代码行数:53,代码来源:zcl_pi.c

示例15: zclPI_Send_MatchProtocolAddrRsp

/*******************************************************************************
 * @fn      zclPI_Send_MatchProtocolAddrRsp
 *
 * @brief   Call to send out a Match Protocol Address Response. This response
 *          is sent back upon receipt of a Match Protocol Address command to
 *          indicate that the Protocol Address was successfully matched.
 *
 * @param   srcEP - Sending application's endpoint
 * @param   dstAddr - where you want the message to go
 * @param   ieeeAddr - device address
 * @param   len - length of protocol address
 * @param   protocolAddr - protocol address
 * @param   disableDefaultRsp - whether to disable the Default Response command
 * @param   seqNum - sequence number
 *
 * @return  ZStatus_t
 */
ZStatus_t zclPI_Send_MatchProtocolAddrRsp( uint8 srcEP, afAddrType_t *dstAddr,
                                           uint8 *ieeeAddr, uint8 len, uint8 *protocolAddr, 
                                           uint8 disableDefaultRsp, uint8 seqNum )
{
  uint8 *buf;
  uint8 msgLen = Z_EXTADDR_LEN + 1 + len; // IEEE Address + 1 for length field
  ZStatus_t stat;

  buf = osal_mem_alloc( msgLen ); // 1 for length field
  if ( buf )
  {
    // Copy over IEEE Address
    osal_cpyExtAddr( buf, ieeeAddr );

    // Copy over Protocol Address
    buf[8] = len;
    osal_memcpy( &(buf[9]), protocolAddr, len );

    stat = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_PI_GENERIC_TUNNEL,
                            COMMAND_PI_GENERIC_TUNNEL_MATCH_PROTOCOL_ADDR_RSP, TRUE, 
                            ZCL_FRAME_SERVER_CLIENT_DIR, disableDefaultRsp, 0, seqNum,
                            msgLen, buf );
    osal_mem_free( buf );
  }
  else
  {
    stat = ZMemError;
  }
  
  return ( stat );
}
开发者ID:binwulang,项目名称:zstack-agriculture,代码行数:48,代码来源:zcl_pi.c


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