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


C++ MEM_Free函数代码示例

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


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

示例1: JVM_Free

/**
 * Deallocates JVM context
 */
STATIC void JVM_Free(JVM * jvm)
{
    if (jvm) {
        if (jvm->hModule) FreeLibrary(jvm->hModule);
        MEM_Free(jvm->versionString);
        MEM_Free(jvm->javaHome);
        MEM_Free(jvm->javaLib);
        MEM_Free(jvm);
    }
}
开发者ID:fedor4ever,项目名称:packaging,代码行数:13,代码来源:jni_win32.c

示例2: ZipInitOut

/**
 * Initializes the output zlib context 
 */
STATIC Bool ZipInitOut(Zip * zf)
{

    /* allocate buffer */
    zf->outbuf = (I8u*)MEM_Alloc(zf->bufsize);
    if (zf->outbuf) {

        /* allocate zlib context */
        zf->out = MEM_New(z_stream);
        if (zf->out) {
            int zerr;
            int bits = ((zf->zflags & ZIP_ZHDR) ? (-MAX_WBITS) : MAX_WBITS);

            /* tell zlib to use our memory allocation functions */
            memset(zf->out, 0, sizeof(*zf->out));
            zf->out->zalloc = ZipMemAlloc;
            zf->out->zfree = ZipMemFree;

            /* windowBits is passed < 0 to suppress zlib header */
            zerr = deflateInit2(zf->out, Z_BEST_COMPRESSION,
                                         Z_DEFLATED, bits, 8,
                                         Z_DEFAULT_STRATEGY);

            if (zerr == Z_OK) {
                if (zf->zflags & ZIP_GZIP) {
                    /* write a very simple .gz header */
                    I8u hdr[10];
                    memset(hdr, 0, sizeof(hdr));
                    hdr[0] = (I8u)GzMagic[0];
                    hdr[1] = (I8u)GzMagic[1];
                    hdr[2] = Z_DEFLATED;
                    hdr[9] = OS_CODE;
                    if (FILE_Write(zf->f,hdr,sizeof(hdr)) == sizeof(hdr)) {
                        FILE_Flush(zf->f);
                        zf->out->next_out = zf->outbuf;
                        zf->out->avail_out = zf->bufsize;
                        return True;
                    }
                } else {
                    /* not writing the header */
                    zf->out->next_out = zf->outbuf;
                    zf->out->avail_out = zf->bufsize;
                    return True;
                }
                deflateEnd(zf->out);
            }
            MEM_Free(zf->out);
            zf->out = NULL;
        }
        MEM_Free(zf->outbuf);
        zf->outbuf = NULL;
    }
    zf->zflags |= ZIP_OUT_ERR;
    return False;
}
开发者ID:fedor4ever,项目名称:packaging,代码行数:58,代码来源:s_fzip.c

示例3: WKQ_ReleaseWorkItem

/**
 * Puts work item to the global pool or deallocates it. Also deallocates 
 * the events associated with the work item. NOTE: this code is designed 
 * to be efficient, not compact
 */
STATIC void WKQ_ReleaseWorkItem(WorkQueueModule * module, WorkItem * w)
{
    Bool locked = False;

    ASSERT(module->initcount > 0);
    ASSERT(!w->submitQ.queue);
    ASSERT(!w->itemsQ.queue);

    /* deallocate waiters */
    while (w->waiters) {
        Waiter * waiter = w->waiters;
        Waiter * next = waiter->next;

        if (module->nwait < module->maxwait) {
            if (locked) {
                WKQ_WaiterToPool(module, waiter);
                waiter = NULL;
            } else {
                locked = MUTEX_Lock(&module->mutex);
                if (module->nwait < module->maxwait) {                    
                    WKQ_WaiterToPool(module, waiter);
                    waiter = NULL;
                }
            }
        }

        if (waiter) {
            EVENT_Destroy(&waiter->event);
            MEM_Free(waiter);
        }

        w->waiters = next;
    }

    if (QUEUE_Size(&module->itempool) < module->maxitems) {
        if (locked) {
            w->flags = WKI_DETACHED;
            QUEUE_InsertTail(&module->itempool, &w->itemsQ);
        } else {
            locked = MUTEX_Lock(&module->mutex);
            if (QUEUE_Size(&module->itempool) < module->maxitems) {
                w->flags = WKI_DETACHED;
                QUEUE_InsertTail(&module->itempool, &w->itemsQ);
            } else {
                MEM_Free(w);
            }
        }
    } else {
        MEM_Free(w);
    }

    if (locked) {
        MUTEX_Unlock(&module->mutex);
    }
}
开发者ID:aharrison24,项目名称:HAL,代码行数:60,代码来源:s_wkq.c

示例4: GWENG_MidpCreateSession

/**
 * Creates MidpSession for the specified XRPC client id. Invoked on the XRPC
 * thread under synchronization.
 */
STATIC MidpSession* GWENG_MidpCreateSession(EcmtGateway* gw, int xrpcSid)
{
    MidpSession* ses = MEM_New(MidpSession);
    if (ses) {
        LUID luid;
        /* Just in case if AllocateLocallyUniqueId fails... */
        luid.LowPart = (DWORD)ses;
        AllocateLocallyUniqueId(&luid);
        memset(ses, 0, sizeof(*ses));
        ses->key.xrpcSid = xrpcSid;
        ses->key.xrpcSession = XRPC_GetCurrentSession(gw->xrpc);
        ses->sid = luid.LowPart;
        ASSERT(!HASH_Contains(&gw->ecmtSessionMap,(HashKey)ses->sid));
        ASSERT(!HASH_Contains(&gw->midpSessionMap,&ses->key));
        if (HASH_Init(&ses->connMap, 1, NULL, NULL, hashFreeValueProc)) {
            /* Create context for the control connection (number zero) */
            MidpConnection* conn = MEM_New(MidpConnection);
            if (conn) {
                memset(conn, 0, sizeof(*conn));
                if (HASH_Put(&ses->connMap, (HashKey)0, conn)) {
                    if (HASH_Put(&gw->ecmtSessionMap,(HashKey)ses->sid,ses)) {
                        if (HASH_Put(&gw->midpSessionMap, &ses->key, ses)) {
                            if (MUTEX_Init(&ses->xrpcMutex)) {
                                ses->xrpcWorkThread = WKQ_Create();
                                if (ses->xrpcWorkThread) {
                                    ses->xrpcWorkItem = WKI_Create(
                                        ses->xrpcWorkThread, GWENG_AsyncXRpc,
                                        ses);
                                    if (ses->xrpcWorkItem) {
                                        QUEUE_Init(&ses->xrpcQueue);
                                        TRACE3("GW: new session %08x for "
                                            "%08x.%08x\n", ses->sid,
                                            ses->key.xrpcSession,
                                            ses->key.xrpcSid);
                                        return ses;
                                    }
                                    WKQ_Delete(ses->xrpcWorkThread);
                                }
                                MUTEX_Destroy(&ses->xrpcMutex);
                            }
                            HASH_Remove(&gw->midpSessionMap, &ses->key);
                        }
                        HASH_Remove(&gw->ecmtSessionMap, (HashKey)ses->sid);
                    }
                } else {
                    MEM_Free(conn);
                }
            }
            HASH_Destroy(&ses->connMap);
        }
        MEM_Free(ses);
    }
    return NULL;
}
开发者ID:fedor4ever,项目名称:packaging,代码行数:58,代码来源:GwSei.c

示例5: freeBlock

/*
 *  ======== freeBlock ========
 *  TO DO: freeBlock() allocates memory, which could result in failure.
 *  Could allocate an RMM_Header in RMM_alloc(), to be kept in a pool.
 *  freeBlock() could use an RMM_Header from the pool, freeing as blocks
 *  are coalesced.
 */
static bool freeBlock(struct RMM_TargetObj *target, u32 segid, u32 addr,
		     u32 size)
{
	struct RMM_Header *head;
	struct RMM_Header *thead;
	struct RMM_Header *rhead;
	bool retVal = true;

	/* Create a memory header to hold the newly free'd block. */
	rhead = MEM_Calloc(sizeof(struct RMM_Header), MEM_PAGED);
	if (rhead == NULL) {
		retVal = false;
	} else {
		/* search down the free list to find the right place for addr */
		head = target->freeList[segid];

		if (addr >= head->addr) {
			while (head->next != NULL && addr > head->next->addr)
				head = head->next;

			thead = head->next;

			head->next = rhead;
			rhead->next = thead;
			rhead->addr = addr;
			rhead->size = size;
		} else {
			*rhead = *head;
			head->next = rhead;
			head->addr = addr;
			head->size = size;
			thead = rhead->next;
		}

		/* join with upper block, if possible */
		if (thead != NULL && (rhead->addr + rhead->size) ==
		   thead->addr) {
			head->next = rhead->next;
			thead->size = size + thead->size;
			thead->addr = addr;
			MEM_Free(rhead);
			rhead = thead;
		}

		/* join with the lower block, if possible */
		if ((head->addr + head->size) == rhead->addr) {
			head->next = rhead->next;
			head->size = head->size + rhead->size;
			MEM_Free(rhead);
		}
	}

	return retVal;
}
开发者ID:MuMu360121,项目名称:jordan-kernel,代码行数:61,代码来源:rmm.c

示例6: JVM_Create

/**
 * Loads the JVM. Every time this method is invoked, it attempts to create 
 * a new JavaVM context. 
 */
JavaVM * JVM_Create(JVM * jvm, int argc, Str args[])
{
    static Str szCreateVM = "JNI_CreateJavaVM";

    /* load the JVM library */
    if (!jvm->hModule) {
        jvm->hModule = LoadLibrary(jvm->javaLib);
        if (jvm->hModule) {
            FARPROC proc = GetProcAddress(jvm->hModule,szCreateVM);
            if (proc) {
                jvm->createVM = (CreateJavaVM)proc;
            } else {
                Error("ERROR: %s not found in %s\n",szCreateVM,jvm->javaLib);
                FreeLibrary(jvm->hModule);
                jvm->hModule = NULL;
            }
        }
    }

    /* create new VM */
    if (jvm->createVM) {
        JavaVMInitArgs vm_args;
        memset(&vm_args, 0, sizeof(vm_args));
        vm_args.version = JNI_VERSION_1_2;
        vm_args.ignoreUnrecognized = JNI_TRUE;
        vm_args.nOptions = argc;
        if (argc) {
            vm_args.options = MEM_NewArray(JavaVMOption,argc);
            if (vm_args.options) {
                int i;
                for (i=0; i<vm_args.nOptions; i++) {
                    JavaVMOption * option = vm_args.options + i;
                    memset(option, 0, sizeof(*option));
                    option->optionString = (char*)args[i];
                }
            }
        }

        if (!argc || vm_args.options) {
            __try {
                JNIEnv * env = NULL;
                JavaVM * vm = NULL;
                int status = jvm->createVM(&vm, (void**)&env, &vm_args);
                ASSERT(status >= 0);
                if (status >= 0) {
                    MEM_Free(vm_args.options);
                    return vm;
                }
            } __except(EXCEPTION_EXECUTE_HANDLER) {
                ASSMSG2("EXCEPTION %08lX in %s",GetExceptionCode(),szCreateVM);
            }
            MEM_Free(vm_args.options);
        }
开发者ID:fedor4ever,项目名称:packaging,代码行数:57,代码来源:jni_win32.c

示例7: EXPAT_StartElement

STATIC void EXPAT_StartElement(void * ctx, XML_Str tag, XML_Str * atts)
{
    ExpatContext * expat = (ExpatContext *)ctx;
    if (expat->cb.startElem) {
        XMLAttr aset;
        XML_Str * s = atts;

        BUFFER_Clear(&expat->buf);
        BUFFER_Clear(&expat->atts);
        while (*s) {
            wchar_t* ws;
            XML_Str xs = *s++;

            /* 
             * store offset in the vector - later will be replaces with the 
             * pointer. Cannot store the pointers now because buffer may be
             * reallocated during conversion. 
             */
            const int off = BUFFER_Size(&expat->buf)/sizeof(Char);
            BUFFER_Put(&expat->atts, &off, sizeof(off), False);

            /* Convert from UTF-8 XML_Str to Str */
            ws = STRING_ToUnicode(xs);
            if (ws) {
#ifdef UNICODE
                BUFFER_Put(&expat->buf,ws,(wcslen(ws)+1)*sizeof(ws[0]),False);
#else
                char * mb = STRING_ToMultiByte(ws);
                if (mb) {
                    BUFFER_Put(&expat->buf, mb, strlen(mb)+1, False);
                    MEM_Free(mb);
                } else {
                    BUFFER_Put(&expat->buf, xs, strlen(xs)+1, False);
                }
#endif
                MEM_Free(ws);
            }
        }

        ASSERT(!((BUFFER_Size(&expat->atts)/sizeof(int))%2));
        aset.storage = BUFFER_Access(&expat->buf);
        aset.size = BUFFER_Size(&expat->buf);
        aset.off = BUFFER_Access(&expat->atts);
        aset.n = BUFFER_Size(&expat->atts)/sizeof(int)/2;

        EXPAT_ConvertTag(&expat->sb, tag);
        (*expat->cb.startElem)(expat->ctx, STRBUF_Text(&expat->sb), &aset);
    }
}
开发者ID:danying,项目名称:v2uros,代码行数:49,代码来源:s_xmlp.c

示例8: DestruirVertice

/***********************************************************************
*
*  Função: GRA Destruir vértice
*
*  Descrição:
*    Função responsável por destruir vértices. Passada como ponteiro de funcao para listas de vértices.
*
***********************************************************************/
void DestruirVertice(void *pVazio)
{
	tpVertice *pVertice = (tpVertice*) pVazio;

	LIS_DestruirLista(pVertice->pAntecessores);
	LIS_DestruirLista(pVertice->pSucessores);

	pVertice->destruirValor(pVertice->pValor);

	MEM_Free(pVertice->nome);

	MEM_Free(pVertice);

	
}
开发者ID:HugoLnx,项目名称:modular-checkmate-judge,代码行数:23,代码来源:grafo.c

示例9: NODEWRAP_GetUUIDProps

/*
 * ======== NODEWRAP_GetUUIDProps ========
 */
u32 NODEWRAP_GetUUIDProps(union Trapped_Args *args, void *pr_ctxt)
{
	DSP_STATUS status = DSP_SOK;
	struct DSP_UUID nodeId;
	struct DSP_NDBPROPS    *pnodeProps = NULL;

	GT_0trace(WCD_debugMask, GT_ENTER,
		 "NODEWRAP_GetUUIDPropste: entered\n");


	cp_fm_usr(&nodeId, args->ARGS_NODE_GETUUIDPROPS.pNodeID, status, 1);
	if (DSP_FAILED(status))
		goto func_cont;
	pnodeProps = MEM_Alloc(sizeof(struct DSP_NDBPROPS), MEM_NONPAGED);
	if (pnodeProps != NULL) {
		status = NODE_GetUUIDProps(args->
					  ARGS_NODE_GETUUIDPROPS.hProcessor,
					  &nodeId, pnodeProps);
		cp_to_usr(args->ARGS_NODE_GETUUIDPROPS.pNodeProps, pnodeProps,
			 status, 1);
	} else
		status = DSP_EMEMORY;
func_cont:
	if (pnodeProps)
		MEM_Free(pnodeProps);
	return status;
}
开发者ID:MuMu360121,项目名称:jordan-kernel,代码行数:30,代码来源:wcd.c

示例10: DIR_ItrFree

STATIC void DIR_ItrFree(Iterator * itr)
{
    Win32DirIterator * w = CAST(itr,Win32DirIterator,common.itr);
    DIR_ItrDestroy(&w->common);
    FindClose(w->handle);
    MEM_Free(w);
}
开发者ID:aharrison24,项目名称:HAL,代码行数:7,代码来源:w_futil.c

示例11: MGRWRAP_EnumNode_Info

/*
 * ======== MGRWRAP_EnumNode_Info ========
 */
u32 MGRWRAP_EnumNode_Info(union Trapped_Args *args, void *pr_ctxt)
{
	u8 *pNDBProps;
	u32 uNumNodes;
	DSP_STATUS status = DSP_SOK;
	u32 size = args->ARGS_MGR_ENUMNODE_INFO.uNDBPropsSize;

	GT_4trace(WCD_debugMask, GT_ENTER,
		 "MGR_EnumNodeInfo: entered args:\n0x%x"
		 " uNode: 0x%x\tpNDBProps: 0x%x\tuNDBPropsSize: "
		 "0x%x\tpuNumNodes\n", args->ARGS_MGR_ENUMNODE_INFO.uNode,
		 args->ARGS_MGR_ENUMNODE_INFO.pNDBProps,
		 args->ARGS_MGR_ENUMNODE_INFO.uNDBPropsSize,
		 args->ARGS_MGR_ENUMNODE_INFO.puNumNodes);
	pNDBProps = MEM_Alloc(size, MEM_NONPAGED);
	if (pNDBProps == NULL)
		status = DSP_EMEMORY;

	if (DSP_SUCCEEDED(status)) {
		status = MGR_EnumNodeInfo(args->ARGS_MGR_ENUMNODE_INFO.uNode,
					 (struct DSP_NDBPROPS *)pNDBProps,
					 size, &uNumNodes);
	}
	cp_to_usr(args->ARGS_MGR_ENUMNODE_INFO.pNDBProps, pNDBProps, status,
		 size);
	cp_to_usr(args->ARGS_MGR_ENUMNODE_INFO.puNumNodes, &uNumNodes, status,
		 1);
	if (pNDBProps)
		MEM_Free(pNDBProps);

	return status;
}
开发者ID:MuMu360121,项目名称:jordan-kernel,代码行数:35,代码来源:wcd.c

示例12: STRMWRAP_FreeBuffer

/*
 * ======== STRMWRAP_FreeBuffer ========
 */
u32 STRMWRAP_FreeBuffer(union Trapped_Args *args, void *pr_ctxt)
{
	DSP_STATUS status = DSP_SOK;
	u8 **apBuffer = NULL;
	u32 uNumBufs = args->ARGS_STRM_FREEBUFFER.uNumBufs;

	DBC_Require(uNumBufs <= MAX_BUFS);

	apBuffer = MEM_Alloc((uNumBufs * sizeof(u8 *)), MEM_NONPAGED);

	cp_fm_usr(apBuffer, args->ARGS_STRM_FREEBUFFER.apBuffer, status,
		 uNumBufs);

	if (DSP_SUCCEEDED(status)) {
		mutex_lock(&((struct PROCESS_CONTEXT *)pr_ctxt)->strm_lock);
		status = STRM_FreeBuffer(args->ARGS_STRM_FREEBUFFER.hStream,
					 apBuffer, uNumBufs, pr_ctxt);
		mutex_unlock(&((struct PROCESS_CONTEXT *)pr_ctxt)->strm_lock);
	}
	cp_to_usr(args->ARGS_STRM_FREEBUFFER.apBuffer, apBuffer, status,
		 uNumBufs);
	if (apBuffer)
		MEM_Free(apBuffer);

	return status;
}
开发者ID:MuMu360121,项目名称:jordan-kernel,代码行数:29,代码来源:wcd.c

示例13: MGRWRAP_EnumProc_Info

/*
 * ======== MGRWRAP_EnumProc_Info ========
 */
u32 MGRWRAP_EnumProc_Info(union Trapped_Args *args, void *pr_ctxt)
{
	u8 *pProcessorInfo;
	u32 uNumProcs;
	DSP_STATUS status = DSP_SOK;
	u32 size = args->ARGS_MGR_ENUMPROC_INFO.uProcessorInfoSize;

	GT_4trace(WCD_debugMask, GT_ENTER,
		 "MGRWRAP_EnumProc_Info: entered args:\n"
		 "0x%x uProcessor: 0x%x\tpProcessorInfo: 0x%x\t"
		 "uProcessorInfoSize: 0x%x\tpuNumProcs \n",
		 args->ARGS_MGR_ENUMPROC_INFO.uProcessor,
		 args->ARGS_MGR_ENUMPROC_INFO.pProcessorInfo,
		 args->ARGS_MGR_ENUMPROC_INFO.uProcessorInfoSize,
		 args->ARGS_MGR_ENUMPROC_INFO.puNumProcs);
	pProcessorInfo = MEM_Alloc(size, MEM_NONPAGED);
	if (pProcessorInfo == NULL)
		status = DSP_EMEMORY;

	if (DSP_SUCCEEDED(status)) {
		status = MGR_EnumProcessorInfo(args->
				ARGS_MGR_ENUMPROC_INFO.uProcessor,
				(struct DSP_PROCESSORINFO *)pProcessorInfo,
				size, &uNumProcs);
	}
	cp_to_usr(args->ARGS_MGR_ENUMPROC_INFO.pProcessorInfo, pProcessorInfo,
		 status, size);
	cp_to_usr(args->ARGS_MGR_ENUMPROC_INFO.puNumProcs, &uNumProcs,
		 status, 1);
	if (pProcessorInfo)
		MEM_Free(pProcessorInfo);

	return status;
}
开发者ID:MuMu360121,项目名称:jordan-kernel,代码行数:37,代码来源:wcd.c

示例14: DBLL_close

/*
 *  ======== DBLL_close ========
 */
void DBLL_close(struct DBLL_LibraryObj *zlLib)
{
	struct DBLL_TarObj *zlTarget;

	DBC_Require(cRefs > 0);
	DBC_Require(MEM_IsValidHandle(zlLib, DBLL_LIBSIGNATURE));
	DBC_Require(zlLib->openRef > 0);
	zlTarget = zlLib->pTarget;
	GT_1trace(DBLL_debugMask, GT_ENTER, "DBLL_close: lib: 0x%x\n", zlLib);
	zlLib->openRef--;
	if (zlLib->openRef == 0) {
		/* Remove library from list */
		if (zlTarget->head == zlLib)
			zlTarget->head = zlLib->next;

		if (zlLib->prev)
			(zlLib->prev)->next = zlLib->next;

		if (zlLib->next)
			(zlLib->next)->prev = zlLib->prev;

		/* Free DOF resources */
		dofClose(zlLib);
		if (zlLib->fileName)
			MEM_Free(zlLib->fileName);

		/* remove symbols from symbol table */
		if (zlLib->symTab)
			GH_delete(zlLib->symTab);

		/* remove the library object itself */
		MEM_FreeObject(zlLib);
		zlLib = NULL;
	}
}
开发者ID:StarKissed,项目名称:android_kernel_omap,代码行数:38,代码来源:dbll.c

示例15: BITSET_Delete

/**
 * Deletes the BitSet
 */
void BITSET_Delete(BitSet * bs)
{
    if (bs) {
        BITSET_Destroy(bs);
        MEM_Free(bs);
    }
}
开发者ID:fedor4ever,项目名称:packaging,代码行数:10,代码来源:s_bitset.c


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