コード例 #1
0
ファイル: Notify.c プロジェクト: zaporozhets/ti_ezsdk_tools
/*
 *  ======== ti_sdo_ipc_Notify_Instance_finalize ========
 */
Void ti_sdo_ipc_Notify_Instance_finalize(ti_sdo_ipc_Notify_Object *obj,
        Int status)
{
    UInt    i;
    UInt16  clusterId = ti_sdo_utils_MultiProc_getClusterId(obj->remoteProcId);

    switch (status) {
    case 0:
        /* Unregister the notify instance from the Notify module */
        Notify_module->notifyHandles[clusterId][obj->lineId] = NULL;

        /* Destruct the event lists */
        for (i = 0; i < ti_sdo_ipc_Notify_numEvents; i++) {
            List_destruct(List_struct(List_Object_get(obj->eventList, i)));
        }

        /* Free memory used for the List.Objects */
        Memory_free(ti_sdo_ipc_Notify_Object_heap(), obj->eventList,
                    sizeof(List_Struct) * ti_sdo_ipc_Notify_numEvents);

    /* OK to fall through */

    case 1:
        /* Free memory used for callbacks array */
        Memory_free(ti_sdo_ipc_Notify_Object_heap(), obj->callbacks,
                    sizeof(ti_sdo_ipc_Notify_EventCallback) *
                    ti_sdo_ipc_Notify_numEvents);
    }
}
コード例 #2
0
/*
 *  ======== task1Fxn ========
 */
Void task1Fxn(UArg arg0, UArg arg1)
{
    Ptr bufs[TASK1NUMBUFS];
    IHeap_Handle heap = HeapMem_Handle_upCast(task1Heap);

    System_printf("Initial task1 heap status\n");

    /* print initial task1Heap status */
    printHeapStats(heap);

    bufs[0] = Memory_alloc(heap, TASK1BUFSIZE0, 0, NULL);

    bufs[1] = Memory_alloc(heap, TASK1BUFSIZE1, 0, NULL);

    bufs[2] = Memory_alloc(heap, TASK1BUFSIZE2, 0, NULL);

    Memory_free(heap, bufs[1], TASK1BUFSIZE1);
    Memory_free(heap, bufs[2], TASK1BUFSIZE2);

    bufs[3] = Memory_alloc(heap, TASK1BUFSIZE3, 0, NULL);

    Memory_free(heap, bufs[0], TASK1BUFSIZE0);
    Memory_free(heap, bufs[3], TASK1BUFSIZE3);

    System_printf("Final task1 heap status\n");

    /* print task1Heap status */
    printHeapStats(heap);

    System_printf("Task1 Complete\n");
}
コード例 #3
0
ファイル: darray.cpp プロジェクト: azizyemloul/taggerXML
NORET Darray_destroy(Darray dyn_ary)
    {
    Darray_rep *temp = dlower(dyn_ary);
    
    Memory_free((VOIDP)temp->storage);
    Memory_free((VOIDP)temp);
    }
コード例 #4
0
ファイル: main.c プロジェクト: GisKook/smarthomebox
Void appTaskFxn(UArg arg0, UArg arg1)
{
	char* args[8];
	//arg[0] is 2 chars for dev type
	args[0] = Memory_alloc(NULL, 2 * sizeof(char), 0, NULL);
	//arg[1] is 3 chars for channel num
	args[1] = Memory_alloc(NULL, 3 * sizeof(char), 0, NULL);

	//init the RPC queue
	rpcInitMq();

	//init the application thread to register the callbacks
	appInit();

	consolePrint(
	        "Enter device type c: Coordinator, r: Router, e: End Device:\n");
	consoleGetLine(args[0], 8);

	consolePrint("Enter channel 11-26:\n");
	consoleGetLine(args[1], 8);

	while (1)
	{
		appProcess(args);
		Task_sleep(10);
	}

	Memory_free(NULL, args[0], 2 * sizeof(char));
	Memory_free(NULL, args[1], 3 * sizeof(char));
}
コード例 #5
0
/*
 *  ======== LoggerBuf_Instance_finalize ========
 */
Void LoggerBuf_Instance_finalize(LoggerBuf_Object *obj, Int status)
{
    if (obj->entryArr != NULL) {
        Memory_free(obj->bufHeap, obj->entryArr,
                    obj->numEntries * sizeof (LoggerBuf_Entry));
    }
}
コード例 #6
0
ファイル: ce.c プロジェクト: Rauf-Kurbanov/trik-v4l2-dsp-fb
static int do_memoryAlloc(CodecEngine* _ce, size_t _srcBufferSize, size_t _dstBufferSize)
{
  memset(&_ce->m_allocParams, 0, sizeof(_ce->m_allocParams));
  _ce->m_allocParams.type = Memory_CONTIGPOOL;
  _ce->m_allocParams.flags = Memory_CACHED;
  _ce->m_allocParams.align = BUFALIGN;
  _ce->m_allocParams.seg = 0;

  _ce->m_srcBufferSize = ALIGN_UP(_srcBufferSize, BUFALIGN);
  if ((_ce->m_srcBuffer = Memory_alloc(_ce->m_srcBufferSize, &_ce->m_allocParams)) == NULL)
  {
    fprintf(stderr, "Memory_alloc(src, %zu) failed\n", _ce->m_srcBufferSize);
    _ce->m_srcBufferSize = 0;
    return ENOMEM;
  }

  _ce->m_dstBufferSize = ALIGN_UP(_dstBufferSize, BUFALIGN);
  if ((_ce->m_dstBuffer = Memory_alloc(_ce->m_dstBufferSize, &_ce->m_allocParams)) == NULL)
  {
    fprintf(stderr, "Memory_alloc(dst, %zu) failed\n", _ce->m_dstBufferSize);
    _ce->m_dstBufferSize = 0;
    Memory_free(_ce->m_srcBuffer, _ce->m_srcBufferSize, &_ce->m_allocParams);
    _ce->m_srcBuffer = NULL;
    _ce->m_srcBufferSize = 0;
    return ENOMEM;
  }

  return 0;
}
コード例 #7
0
ファイル: MessageQ.c プロジェクト: andreimironenko/ipc
/*
 *  ======== MessageQ_free ========
 */
Int MessageQ_free(MessageQ_Msg msg)
{
    IHeap_Handle heap;

    /* make sure msg is not NULL */
    Assert_isTrue((msg != NULL), ti_sdo_ipc_MessageQ_A_invalidMsg);
    
    /* Cannot free a message that was initialized via MessageQ_staticMsgInit */
    Assert_isTrue((msg->heapId != ti_sdo_ipc_MessageQ_STATICMSG), 
                  ti_sdo_ipc_MessageQ_A_cannotFreeStaticMsg);
    
    Assert_isTrue((msg->heapId < MessageQ_module->numHeaps),
                  ti_sdo_ipc_MessageQ_A_heapIdInvalid);

    Assert_isTrue((MessageQ_module->heaps[msg->heapId] != NULL),
                  ti_sdo_ipc_MessageQ_A_heapIdInvalid);

    if ((ti_sdo_ipc_MessageQ_traceFlag == TRUE) ||
        (msg->flags & ti_sdo_ipc_MessageQ_TRACEMASK) != 0) {                    
        Log_write3(ti_sdo_ipc_MessageQ_LM_free, (UArg)(msg), 
            (UArg)(msg->seqNum), (UArg)(msg->srcProc));
    }
    
    heap = MessageQ_module->heaps[msg->heapId];
    
    if (heap != NULL) {
        Memory_free(heap, msg, msg->msgSize);
    }
    else {
        return (MessageQ_E_FAIL);
    }

    return (MessageQ_S_SUCCESS);
}
コード例 #8
0
ファイル: Power.c プロジェクト: alexeicolin/sysbios
/*
 *  ======== Power_unregisterConstraint ========
 *  Unregister for a power notification.
 *
 */
Power_Status Power_unregisterConstraint(Power_ConstraintHandle handle)
{
    Power_Status status = Power_SOK;
    Power_Constraint type;
    UInt key;

    /* check for NULL constraintHandle */
    if (handle == NULL) {
        status = Power_EINVALIDHANDLE;
    }

    /* else, remove and delete constraint object, update aggregate constraint */
    else {
        key = Hwi_disable();
        Queue_remove((Queue_Elem *)handle);
        Hwi_restore(key);

        /* recompute aggregate constraint w/absence of removed constraint */
        type = ((Power_ConstraintObj *) handle)->type;
        Power_rebuildConstraint(type);

        /* free the constraint object */
        Memory_free(Power_Object_heap(), handle, sizeof(Power_ConstraintObj));
    }

    return (status);
}
コード例 #9
0
ファイル: Algorithm_BIOS.c プロジェクト: mobiaqua/ti-ce
/*
 *  ======== Algorithm_delete ========
 */
Void Algorithm_delete(Algorithm_Handle alg)
{
    Algorithm_Obj *pObject = (Algorithm_Obj *)alg;
    IRES_Status status;

    Log_print1(Diags_ENTRY, "[+E] Algorithm_delete> Enter(alg=0x%x)",
            (IArg)alg);

    if (pObject != NULL) {
        if (pObject->iresFxns) {
            /* Call RMAN fuction to free resources */
            status = RMAN_freeResources(pObject->alg, pObject->iresFxns,
                    pObject->groupId);
            if (status != IRES_OK) {
                Log_print1(Diags_USER7, "[+7] Algorithm_delete> Freeing "
                        "of alg resources through RMAN FAILED (0x%x)",
                        (IArg)status);
            }
        }

        if (pObject->alg) {
            DSKT2_freeAlg(pObject->groupId, pObject->alg);
        }

        Memory_free(pObject, sizeof (*pObject), NULL);
    }

    Log_print0(Diags_EXIT, "[+X] Algorithm_delete> Exit");
}
コード例 #10
0
/*
 *  ======== Algorithm_delete ========
 */
Void Algorithm_delete(Algorithm_Handle alg)
{
    Algorithm_Obj *pObject = (Algorithm_Obj *)alg;
    IRES_Status status;

    Log_print1(Diags_ENTRY, "[+E] Algorithm_delete> Enter(alg=0x%x)",
            (IArg)alg);

    if (pObject != NULL) {
        if (pObject->iresFxns) {
            /* Call RMAN fuction to free resources */
            status = RMAN_freeResources(pObject->alg, pObject->iresFxns,
                    pObject->groupId);
            if (status != IRES_OK) {
                Log_print1(Diags_USER7, "[+7] Algorithm_delete> Freeing "
                        "of alg resources through RMAN FAILED (0x%x)",
                        (IArg)status);
            }
        }

        if (pObject->idma3Fxns) {
            Log_print0(Diags_USER4, "[+4] Algorithm_delete> releasing "
                    "DMA resources");
            DMAN3_releaseDmaChannels(&(pObject->alg), &(pObject->idma3Fxns),1);
        }

        if (pObject->alg) {
            ALG_delete(pObject->groupId, pObject->alg, pObject->useCachedMem);
        }

        Memory_free(pObject, sizeof (*pObject), NULL);
    }

    Log_print0(Diags_EXIT, "[+X] Algorithm_delete> Exit");
}
コード例 #11
0
ファイル: xdm_server.c プロジェクト: andreimironenko/rpe
void _XdmServer_freeXdaisAlgMemory(IALG_MemRec memTab[], Int numRecs)
{
    Int idx;
    uint8_t                 *handle;
    uint8_t                 *RPE_dspIramHeapHandle = globaL2heap;
    
    for (idx = 0; idx < numRecs; idx++) 
    {
        if (memTab[idx].base != NULL) 
        {
            if ( memTab[idx].space > IALG_SARAM2 ) 
            { 
                handle = RPE_dspAlgHeapHandle;
            }
            else
            {
                handle = RPE_dspIramHeapHandle;
            }

            /* Freeing a buffer of size 0 is not possible, so we allocate     */
            /* 8 bytes during creation. This is taken care during deletion    */
            if (memTab[idx].size == 0)
            {
                memTab[idx].size = 8;
            }
            
            Memory_free ((IHeap_Handle) handle, memTab[idx].base, memTab[idx].size);
        }
    }
    return;
}
コード例 #12
0
ファイル: mem.c プロジェクト: CheredHerry/ti-bios
/*
 *  ======== MEM_increaseTableSize ========
 */
Int MEM_increaseTableSize(Uns numEntries)
{
    IArg                key;
    IHeap_Handle       *tmpTable;
    Error_Block         eb;
    
    Error_init(&eb);

    /* Use HeapMem's gate for thread-safety */
    key = HeapMem_enter();

    tmpTable = Memory_calloc(MEM_table[0],
        (MEM_tabSize + numEntries) * sizeof(IHeap_Handle), 0, NULL);
    
    if (tmpTable == NULL) {
        HeapMem_leave(key);
        return (SYS_EALLOC);
    }

    memcpy(tmpTable, MEM_table, MEM_tabSize * sizeof(IHeap_Handle));

    if ((MEM_tabSize != 0) && (staticTable != TRUE)) {
        Memory_free(MEM_table[0], MEM_table, MEM_tabSize * sizeof(IHeap_Handle));
    }

    staticTable = FALSE;
    MEM_table = tmpTable;
    MEM_tabSize += numEntries;

    HeapMem_leave(key);

    return (SYS_OK);
}
コード例 #13
0
ファイル: Buffer.c プロジェクト: Soorma07/dvsdk-dmai
/******************************************************************************
 * Buffer_copy
 ******************************************************************************/
Int Buffer_copy(Buffer_Handle hSrcBuf, Buffer_Handle hDstBuf)
{
    assert(hSrcBuf);
    assert(hDstBuf);
    assert(hSrcBuf->type == Buffer_Type_BASIC ||
           hSrcBuf->type == Buffer_Type_GRAPHICS);

    if(hSrcBuf->type != hDstBuf->type) {
        Dmai_err1("Cannot copy to Buffer type (%d)\n", hDstBuf->type);
        return Dmai_EFAIL;
    }

    if (!hDstBuf->reference && hDstBuf->userPtr) {
        Dmai_dbg3("Free Buffer of size %u at 0x%x (0x%x phys)\n",
                  (Uns) hDstBuf->origState.numBytes,
                  (Uns) hDstBuf->userPtr,
                  (Uns) hDstBuf->physPtr);

        if (!Memory_free(hDstBuf->userPtr, hDstBuf->origState.numBytes,
                         &hDstBuf->memParams)) {
            return Dmai_EFAIL;
        }
    }

    if(hSrcBuf->type == Buffer_Type_GRAPHICS) {
        *(_BufferGfx_Object *) hDstBuf = *(_BufferGfx_Object *) hSrcBuf;
    } else {
        *(_Buffer_Object *) hDstBuf = *(_Buffer_Object *) hSrcBuf;
    }

    hDstBuf->reference = TRUE;

    return Dmai_EOK;
}
コード例 #14
0
/*
 *  ======== Swi_Instance_finalize ========
 *  free hookEnv if alloced during create
 */
Void Swi_Instance_finalize(Swi_Object *swi, Int status)
{
#ifndef ti_sysbios_knl_Swi_DISABLE_ALL_HOOKS
    Int i, cnt;
#endif

    if (status == 1) {
        return;
    }

    /* Can't delete a currently posted Swi */
    Assert_isTrue((swi->posted == 0), NULL);

#ifndef ti_sysbios_knl_Swi_DISABLE_ALL_HOOKS
    if (Swi_hooks.length > 0) {
        if (status == 0) {
            cnt = Swi_hooks.length;
        }
        else {
            cnt = status - 2;
        }

        for (i = 0; i < cnt; i++) {
            if (Swi_hooks.elem[i].deleteFxn != NULL) {
                Swi_hooks.elem[i].deleteFxn(swi);
            }
        }

        Memory_free(Swi_Object_heap(), swi->hookEnv,
                Swi_hooks.length * sizeof (Ptr));
    }
#endif
}
コード例 #15
0
/*
 *  ======== NODE_delete ========
 */
Int NODE_delete(NODE_Handle node)
{
    Void   *handle;

    /* Should be a DBC_requires */
    Assert_isTrue(node != NULL, (Assert_Id)NULL);
    Assert_isTrue(node->skelFxns != NULL, (Assert_Id)NULL);
    Assert_isTrue(node->skelFxns->apiDestroy != NULL, (Assert_Id)NULL);

    /* delete thread *before* destroying node to ensure thread has no access
     * to node as we are freeing it
     */
    if (node->self) {
        Log_print1(Diags_ENTRY, "[+E] NODE_delete(0x%x)", (IArg)node);

        Thread_delete(&(node->self));
    }

    handle = NODE_getEnv(node);

    if (handle) {
        node->skelFxns->apiDestroy(handle);
    }

    if (node->recv != Comm_INVALIDHANDLE) {
        Comm_delete(node->recv);
    }

    Memory_free(NULL, node, sizeof(NODE_Obj));

    return (NODE_EOK);
}
コード例 #16
0
/*
 *  ======== task0Fxn ========
 */
Void task0Fxn(UArg arg0, UArg arg1)
{
    Int i;
    Ptr bufs[TASK0NUMBUFS];

    IHeap_Handle heap = HeapBuf_Handle_upCast(task0Heap);

    System_printf("Initial task0 heap status\n");

    /* print initial task0heap status */
    printHeapStats(heap);

    /* allocate blocks from task0Heap */
    for (i = 0; i < TASK0NUMBUFS; i++) {
        bufs[i] = Memory_alloc(heap, TASK0BUFSIZE, 0, NULL);
    }

    /* free memory blocks */
    for (i = 0; i < TASK0NUMBUFS; i++) {
        Memory_free(heap, bufs[i], TASK0BUFSIZE);
    }

    System_printf("Final task0 heap status\n");

    /* print task0Heap status */
    printHeapStats(heap);

    System_printf("Task0 Complete\n");
}
コード例 #17
0
Int SystemCfg_deleteResources(SystemCfg_Object *obj)
{
    IHeap_Handle        heapH;
    Int                 status = 0;


    Log_print1(Diags_ENTRY | Diags_INFO, "--> "FXNN": (obj=0x%x)",(IArg)obj);

    /* delete opencl buffer heap */
//  HeapBufMP_delete(&obj->openclHeapH);

    /* unregister rcm message heap with MessageQ */
    MessageQ_unregisterHeap(SystemCfg_RcmMsgHeapId_CompDev);

    /* delete rcm message heap instance */
    HeapBuf_delete(&obj->rcmHeapH);

    /* free the rcm message heap storage */
    heapH = (IHeap_Handle)SharedRegion_getHeap(0);
    Memory_free(heapH, obj->rcmHeapBufBase, obj->rcmHeapBufSize);
    obj->rcmHeapBufBase = NULL;
    obj->rcmHeapBufSize = 0;

    Log_print1(Diags_EXIT, "<-- "FXNN": %d", (IArg)status);
    return(status);
}
コード例 #18
0
/*
 *  ======== Global_exit ========
 *  calls cleanup functions for all the modules that
 *  scheduled it, then cleans up itself
 */
Void Global_exit(Void)
{
    ExitFxnElem *old;

    if (curInit == FALSE) {
        return;
    }

    Log_print0(Diags_ENTRY, "[+E] Global_exit> enter" );

    while( exitFxnList != NULL ) {
        Log_print1(Diags_USER2, "[+2] Global_exit> "
                   "calling function *0x%x()...", (IArg)(exitFxnList->fxn ));
        exitFxnList->fxn();
        old = exitFxnList;
        exitFxnList = exitFxnList->next;
        Memory_free(NULL, old, sizeof(ExitFxnElem));
    }

    /* if the tracing module has its exit function, it must have been
     * the last one, so don't use trace from this point on
     */

    /* do the cleanup of this module */
    curInit          = FALSE;
    exitFxnList      = NULL;  /* unnecessary, NULL already */

    /* we do NOT reset doRegisterAtExit, as we don't want endless pairs of
     * CERuntime_init/exit to keep adding this func to the process' atexit
     * table. Autoexit is a curtesy feature only for those who call
     * CERuntime_init once.
     */
    /* doRegisterAtExit = TRUE; */
}
コード例 #19
0
/*!
 *  @brief      Function to finalize the HAL object
 *
 *  @param      halObj      Pointer to the HAL object
 *
 *  @sa         OMAPL1XX_halInit
 *              OMAPL1XX_phyShmemExit
 */
Int
OMAPL1XX_halExit (Ptr halObj)
{
    Int                  status    = PROCESSOR_SUCCESS;
    OMAPL1XX_HalObject * halObject = NULL;

    GT_1trace (curTrace, GT_ENTER, "OMAPL1XX_halExit", halObj);

    GT_assert (curTrace, (halObj != NULL));

    halObject = (OMAPL1XX_HalObject *) halObj ;
    status = OMAPL1XX_phyShmemExit (halObj);
#if !defined(SYSLINK_BUILD_OPTIMIZE)
    if (status < 0) {
        GT_setFailureReason (curTrace,
                             GT_4CLASS,
                             "OMAPL1XX_halExit",
                             status,
                             "OMAPL1XX_phyShmemExit failed!");
    }
#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */

    if (halObj != NULL) {
        /* Free the memory for the HAL object. */
        Memory_free (NULL, halObj, sizeof (OMAPL1XX_HalObject));
    }

    GT_1trace (curTrace, GT_LEAVE, "OMAPL1XX_halExit", status);

    /*! @retval PROCESSOR_SUCCESS Operation successful */
    return status;
}
コード例 #20
0
ファイル: utils_mem.c プロジェクト: sdut10523/dvr_rdk
Int32 Utils_memFree(Ptr addr, UInt32 size)
{
    UInt32 heapId = UTILS_MEM_VID_FRAME_BUF_HEAP;
    SharedRegion_Entry srEntry;

   SharedRegion_getEntry(SYSTEM_IPC_SR_VIDEO_FRAME, &srEntry);

    /* if address falls in tiler buffer then free from that heap */
    if((UInt32)addr >= (UInt32)srEntry.base && (UInt32)addr < ((UInt32)srEntry.base + srEntry.len) )
    {
        #ifdef UTILS_MEM_DEBUG
        Vps_printf(" UTILS: MEM: FRAME FREE, addr = 0x%08x, size = %d bytes, heap = %d\n", addr, size, heapId);
        #endif

        /* free previously allocated memory */
        Memory_free(gUtils_heapMemHandle[heapId], addr, size);
    }
    else
    {
        Int32 status;

        status = SystemTiler_freeRaw(addr,size);
        UTILS_assert(status == 0);
    }

    return 0;
}
コード例 #21
0
/*!
 *  @brief      Remove and delete entry from the Translation Table
 *
 *  @param      da      Device address
 *
 *  @sa         _SysLinkMemUtils_insertMapElement
 */
static Ptr
_SysLinkMemUtils_removeMapElement (Ptr da)
{
    AddrNode  * node;
    Ptr         addr = NULL;

    GT_1trace (curTrace, GT_ENTER, "_SysLinkMemUtils_removeMapElement", da);

    OsalSemaphore_pend (SysLinkMemUtils_module->semList,
                        OSALSEMAPHORE_WAIT_FOREVER);
    node = _SysLinkMemUtils_findNode (da);
    if (!node || node->da != da) {
#if !defined(SYSLINK_BUILD_OPTIMIZE)
        GT_setFailureReason (curTrace,
                             GT_4CLASS,
                             (Char *)__func__,
                             PROCMGR_E_FAIL,
                             "Entry not found!");
#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
    }
    else {
        addr = node->ua;
        List_remove (SysLinkMemUtils_module->addrTable, &node->elem);
        Memory_free (NULL, node, sizeof (AddrNode));
    }
    OsalSemaphore_post (SysLinkMemUtils_module->semList);

    GT_1trace (curTrace, GT_LEAVE, "_SysLinkMemUtils_removeMapElement", addr);

    return addr;
}
コード例 #22
0
ファイル: IpcResource.c プロジェクト: GAnthony/sysbios-rpmsg
Int IpcResource_disconnect(IpcResource_Handle handle)
{
    Int status;
    IpcResource_Req req;

    if (!handle) {
        System_printf("IpcResource_disconnect: handle is NULL\n");
    }

    req.resType = 0;
    req.reqType = IpcResource_REQ_TYPE_DISCONN;

    status = MessageQCopy_send(MultiProc_getId("HOST"), IpcResource_server,
                        handle->endPoint, &req, sizeof(req));
    if (status) {
        System_printf("IpcResource_disconnect: MessageQCopy_send "
                      "failed status %d\n", status);
        return status;
    }

    status = MessageQCopy_delete(&handle->msgq);
    if (status) {
        System_printf("IpcResource_disconnect: MessageQCopy_delete "
                      "failed status %d\n", status);
        return status;
    }

    Memory_free(NULL, handle, sizeof(*handle));

    return 0;
}
コード例 #23
0
ファイル: HeapMultiBuf.c プロジェクト: andreimironenko/bios
/*
 *  ======== HeapMultiBuf_Instance_finalize ========
 *  Deletes the managed HeapBuf instances and frees the memory for the 
 *  sorted buffer arrays.
 */
Void HeapMultiBuf_Instance_finalize(HeapMultiBuf_Object *obj, int status)
{
    Int i;
    
    /* If a create failed, handle the finalize based on the status. */
    switch (status) {
        /* Alloc of bufsByAddr failed. */
        case 1:
            return;
        /* Alloc of bufsBySize failed. */
        case 2:
            /* bufsByAddr succeeded, so free bufsByAddr. */
            Memory_free(NULL, obj->bufsByAddr, obj->numBufs * sizeof(HeapMultiBuf_AddrPair));
            return;
        case 3:
            /* Delete any heapBufs that were successfully created. */
            for (i = 0; i < obj->numBufs; i++) {
                /* 
                 * bufsBySize was calloc'd, so we can check for NULL to find
                 * the end of the created HeapBufs.
                 */
                if (&(obj->bufsBySize[i]) == NULL) {
                    break;
                }
                
                HeapBuf_delete(&(obj->bufsBySize[i]));
            }
            /* Free both the bufsByAddr and bufsBySize arrays. */
            Memory_free(NULL, obj->bufsByAddr, obj->numBufs * sizeof(HeapMultiBuf_AddrPair));
            Memory_free(NULL, obj->bufsBySize, obj->numBufs * sizeof(HeapBuf_Object*));
            return;
    }
    
    /* 
     * If finalize is being called through a normal delete, rather than
     * through a failed create...
     */
     
    /* Delete all of the created HeapBufs */
    for (i = 0; i < obj->numBufs; i++) {
        HeapBuf_delete(&(obj->bufsBySize[i]));
    }
    
    /* Free the bufsByAddr and bufsBySize arrays. */
    Memory_free(NULL, obj->bufsByAddr, obj->numBufs * sizeof(HeapMultiBuf_AddrPair));
    Memory_free(NULL, obj->bufsBySize, obj->numBufs * sizeof(HeapBuf_Object*));
}
コード例 #24
0
/*
 *  ======== Comm_create ========
 */
Comm_Handle Comm_create(String queueName, Comm_Attrs *attrs)
{
    Comm_Obj   *comm;
    UInt32      commId;
    Char        commName[ MAXCOMMNAMELEN ];
    key_t       key;

    Assert_isTrue(curInit > 0, (Assert_Id)NULL);

    Log_print2(Diags_ENTRY, "[+E] Comm_create> "
            "Enter(queueName='%s', attrs=0x%x)", (IArg)queueName, (IArg)attrs);

    if (attrs == NULL) {
        attrs = &Comm_ATTRS;
    }

    if (queueName == NULL) {
        /* Generate a name to use */
        // TODO: Increment curCommId atomically
        commId = curCommId++;
        sprintf(commName, "queue_%lu_%u", Global_getProcessId(), (Uns)commId);
        key = nameToId(commName);
    }
    else {
        key = nameToId(queueName);
    }

    comm = (Comm_Obj *)Memory_alloc(NULL, sizeof(Comm_Obj), 0, NULL);
    if (comm == NULL) {
        return (NULL);
    }

    comm->type = attrs->type;

    if (comm->type == Comm_PEND) {
        ;
    }
    else if (comm->type == Comm_CALL) {
        comm->callHandle = attrs->callHandle;
        comm->callFxn    = attrs->callFxn;
    }
    else {
        Assert_isTrue(FALSE, (Assert_Id)NULL);  /* unknown Comm type */
    }

    /*
     * Create a new message queue id for the "name" key
     */
    if ((comm->id = msgget(key, IPC_CREAT | 0644)) < 0) {
        fprintf(stderr, "msgget key = 0x%x\n", key);
        perror("Comm_create:msgget");
        Memory_free(NULL, comm, sizeof(Comm_Obj));
        return (NULL);
    }

    Log_print1(Diags_EXIT, "[+X] Comm_create> return (0x%x)", (IArg)comm);

    return (comm);
}
コード例 #25
0
/*
 *  ======== cleanup ========
 */
static Void cleanup(Void)
{
    Assert_isTrue(curInit > 0, (Assert_Id)NULL);

    if (--curInit == 0) {
        /* Free library search path buffers */
        if (libPath) {
            Memory_free(NULL, libPath, pathLen);
            libPath = NULL;
        }
        if (tmpPath) {
            Memory_free(NULL, tmpPath, pathLen);
            tmpPath = NULL;
        }
        pathLen = 0;
    }
}
コード例 #26
0
ファイル: ce.c プロジェクト: guyz/dsp
 void
cont_free_frames(struct frame *frames, unsigned nf)
{
    int i;
    if (frames) {
       for (i=0; i<nf; i++) {
           if (frames[i].virt[0]) {
		//Memory_registerContigBuf((UInt32) frames[i].virt[0], ce_frame_size, (UInt32)frames[i].phys[0]);
	   	Memory_free(frames[i].virt[0], ce_frame_size, &mem_params);
	   }
       }
    }

    if (frames) free(frames); //TODO: reference this

    Memory_free(input_buf, INPUT_BUFFER_SIZE, &mem_params);

}
コード例 #27
0
ファイル: ce.c プロジェクト: Rauf-Kurbanov/trik-v4l2-dsp-fb
static int do_memoryFree(CodecEngine* _ce)
{
  if (_ce->m_dstBuffer != NULL)
  {
    Memory_free(_ce->m_dstBuffer, _ce->m_dstBufferSize, &_ce->m_allocParams);
    _ce->m_dstBuffer = NULL;
    _ce->m_dstBufferSize = 0;
  }

  if (_ce->m_srcBuffer != NULL)
  {
    Memory_free(_ce->m_srcBuffer, _ce->m_srcBufferSize, &_ce->m_allocParams);
    _ce->m_srcBuffer = NULL;
    _ce->m_srcBufferSize = 0;
  }

  return 0;
}
コード例 #28
0
ファイル: Memory.c プロジェクト: programble/proxos
void *Memory_reallocate(void *memory, u32 size)
{
    void *new = Memory_allocate(size);
    Memory_Header *header = Memory_Header_fromBlock(memory);
    Memory_Header_assertMagic(header);
    String_copy(new, memory, (size < header->size) ? size : header->size);
    Memory_free(memory);

    return new;
}
コード例 #29
0
/*
 *  ======== ffcio_close ========
 */
int ffcio_close(int dev_fd)
{
    f_close(filTable[dev_fd]);

    Memory_free(NULL, filTable[dev_fd], sizeof(FIL));

    filTable[dev_fd] = NULL;

    return (0);
}
コード例 #30
0
ファイル: dskt2_permute.c プロジェクト: mobiaqua/ti-fc
void _DSKT2_Permute_deleteHandle(_DSKT2_PERMUTE_EnumerationHandle h)
{
    if (NULL != h) {
#ifdef _RTSMODE_
        free(h);
#else
        Memory_free(_DSKT2_heap, h, sizeof(_DSKT2_PERMUTE_Enumeration));
#endif
    }
}