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

C++ HASH_FIND_PTR函数代码示例

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

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



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

示例1: heapStatsCallback

static int heapStatsCallback(void* ptr, unsigned char kind, size_t sz, int live, void* _data) {
    HeapStatsCallbackData* data = (HeapStatsCallbackData*) _data;
    LoadedClass* loadedClasses = data->loadedClasses;
    HeapStat** statsHashPtr = data->statsHashPtr;

    Class* key = NULL;
    if (kind == GC_gcj_kind || kind == objectArrayGCKind) {
        Object* obj = (Object*) ptr;
        if (obj && obj->clazz) {
            LoadedClass* loadedClass;
            HASH_FIND_PTR(loadedClasses, &(obj->clazz), loadedClass);
            if (!loadedClass) {
                return 0; // Don't clear this object
            }
            key = obj->clazz;
        }
    }

    HeapStat* stat;
    HASH_FIND_PTR(*statsHashPtr, &key, stat);
    if (!stat) {
        stat = calloc(1, sizeof(HeapStat));
        stat->key = key;
        HASH_ADD_PTR(*statsHashPtr, key, stat);
    }
    stat->numberOfInstances++;
    stat->numberOfBytes += sz;
    if (live) {
        stat->numberOfLiveInstances++;
        stat->numberOfLiveBytes += sz;
    }
    return 0; // live ? 0 : 1;
}
开发者ID:Svyatoslavik,项目名称:robovm,代码行数:33,代码来源:memory.c


示例2: shader

/******************************************************************************
 tv_material_compile_shader
 Compiles the given shader (first looking to see if the shader already has 
 been loaded by checking the appropriate "loaded_XXX_shaders" table. 
 *****************************************************************************/
GLuint tv_material_compile_shader(tvchar* file, tvuint type)
{
	TvMaterialShader* lup;
	tvchar* buffer;
	TvMaterialShader* shader_table;
	GLuint shader_handle;

	/* look up the shader - has it been loaded already? */
	HASH_FIND_PTR(loaded_vertex_shaders, file, lup);
	switch(type) {
	case GL_VERTEX_SHADER: shader_table = loaded_fragment_shaders;  break;
	case GL_FRAGMENT_SHADER: shader_table = loaded_vertex_shaders; break;
	case GL_GEOMETRY_SHADER: shader_table = loaded_geometry_shaders; break;
	case GL_TESS_CONTROL_SHADER: shader_table = loaded_tesselation_control_shaders; break; 
	case GL_TESS_EVALUATION_SHADER: shader_table = loaded_tesselation_evaluation_shaders; break;
	default: tv_warning("unrecognized shader type"); return;
	}
	/* look up the shader */
	HASH_FIND_PTR(shader_table, file, lup); 
	/* if the shader has already been loaded, return it's handle. */
	if(lup) {
		return (GLuint)lup->id;
	}
	/* shader has NOT been loaded, let's load it */
	UtilReadFile(file, &buffer);
	shader_handle = compile_gl_shader(buffer, type);
	lup = (TvMaterialShader*)tv_alloc(sizeof(TvMaterialShader));
	lup->name = file;
	lup->id = shader_handle;
	HASH_ADD_PTR(shader_table, name, lup);
	free(buffer);
	return (GLuint)shader_handle;
}
开发者ID:gummyworm,项目名称:evo,代码行数:38,代码来源:material.c


示例3: DestroyPixmap

static Bool
DestroyPixmap(PixmapPtr pPixmap)
{
    ScreenPtr pScreen = pPixmap->drawable.pScreen;
    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
    Rk30MaliPtr rk_3d = FBDEVPTR(pScrn)->Rk30Mali;
    Bool result;
    UMPBufferInfoPtr umpbuf;
    HASH_FIND_PTR(rk_3d->HashPixmapToUMP, &pPixmap, umpbuf);

    if (umpbuf) {
        DebugMsg("DestroyPixmap %p for migrated UMP pixmap (UMP buffer=%p)\n", pPixmap, umpbuf);

        pPixmap->devKind = umpbuf->BackupDevKind;
        pPixmap->devPrivate.ptr = umpbuf->BackupDevPrivatePtr;

        ump_mapped_pointer_release(umpbuf->handle);
        ump_reference_release(umpbuf->handle);

        HASH_DEL(rk_3d->HashPixmapToUMP, umpbuf);
        DebugMsg("umpbuf->refcount=%d\n", umpbuf->refcount);
        if (--umpbuf->refcount <= 0) {
            DebugMsg("free(umpbuf)\n");
            free(umpbuf);
        }
    }

    pScreen->DestroyPixmap = rk_3d->DestroyPixmap;
    result = (*pScreen->DestroyPixmap) (pPixmap);
    rk_3d->DestroyPixmap = pScreen->DestroyPixmap;
    pScreen->DestroyPixmap = DestroyPixmap;


    return result;
}
开发者ID:davidftv,项目名称:xf86-video-fbdev,代码行数:35,代码来源:mali_dri2.c


示例4: MigratePixmapToUMP

/* Migrate pixmap to UMP buffer */
static UMPBufferInfoPtr
MigratePixmapToUMP(PixmapPtr pPixmap)
{
    ScreenPtr pScreen = pPixmap->drawable.pScreen;
    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
    Rk30MaliPtr rk_3d = FBDEVPTR(pScrn)->Rk30Mali;
    UMPBufferInfoPtr umpbuf;
    size_t pitch = ((pPixmap->devKind + 7) / 8) * 8;
    size_t size = pitch * pPixmap->drawable.height;

    HASH_FIND_PTR(rk_3d->HashPixmapToUMP, &pPixmap, umpbuf);

    if (umpbuf) {
        DebugMsg("MigratePixmapToUMP %p, already exists = %p\n", pPixmap, umpbuf);
        return umpbuf;
    }

    /* create the UMP buffer */
    umpbuf = calloc(1, sizeof(UMPBufferInfoRec));
    if (!umpbuf) {
        ErrorF("MigratePixmapToUMP: calloc failed\n");
        return NULL;
    }
    umpbuf->refcount = 1;
    umpbuf->pPixmap = pPixmap;
    umpbuf->handle = ump_ref_drv_allocate(size, UMP_REF_DRV_CONSTRAINT_PHYSICALLY_LINEAR);
    if (umpbuf->handle == UMP_INVALID_MEMORY_HANDLE) {
        ErrorF("MigratePixmapToUMP: ump_ref_drv_allocate failed\n");
        free(umpbuf);
        return NULL;
    }
    umpbuf->size = size;
    umpbuf->addr = ump_mapped_pointer_get(umpbuf->handle);
    umpbuf->depth = pPixmap->drawable.depth;
    umpbuf->width = pPixmap->drawable.width;
    umpbuf->height = pPixmap->drawable.height;

    /* copy the pixel data to the new location */
    if (pitch == pPixmap->devKind) {
        memcpy(umpbuf->addr, pPixmap->devPrivate.ptr, size);
    } else {
        int y;
        for (y = 0; y < umpbuf->height; y++) {
            memcpy(umpbuf->addr + y * pitch, 
                   pPixmap->devPrivate.ptr + y * pPixmap->devKind,
                   pPixmap->devKind);
        }
    }

    umpbuf->BackupDevKind = pPixmap->devKind;
    umpbuf->BackupDevPrivatePtr = pPixmap->devPrivate.ptr;

    pPixmap->devKind = pitch;
    pPixmap->devPrivate.ptr = umpbuf->addr;

    HASH_ADD_PTR(rk_3d->HashPixmapToUMP, pPixmap, umpbuf);

    DebugMsg("MigratePixmapToUMP %p, new buf = %p\n", pPixmap, umpbuf);
    return umpbuf;
}
开发者ID:davidftv,项目名称:xf86-video-fbdev,代码行数:61,代码来源:mali_dri2.c


示例5: HASH_FIND_PTR

inline js_proxy_t *js_get_or_create_proxy(JSContext *cx, T *native_obj) {
    js_proxy_t *proxy;
    HASH_FIND_PTR(_native_js_global_ht, &native_obj, proxy);
    if (!proxy) {
        js_type_class_t *typeProxy = js_get_type_from_native<T>(native_obj);
        // Return NULL if can't find its type rather than making an assert.
//        assert(typeProxy);
        if (!typeProxy) {
            CCLOGINFO("Could not find the type of native object.");
            return NULL;
        }
        
        JSObject* js_obj = JS_NewObject(cx, typeProxy->jsclass, typeProxy->proto, typeProxy->parentProto);
        proxy = jsb_new_proxy(native_obj, js_obj);
#ifdef DEBUG
        JS_AddNamedObjectRoot(cx, &proxy->obj, typeid(*native_obj).name());
#else
        JS_AddObjectRoot(cx, &proxy->obj);
#endif
        return proxy;
    } else {
        return proxy;
    }
    return NULL;
}
开发者ID:kun-g,项目名称:client,代码行数:25,代码来源:cocos2d_specifics.hpp


示例6: CCASSERT

// XXX: Passing "const O *" instead of "const O&" because HASH_FIND_IT requries the address of a pointer
// and, it is not possible to get the address of a reference
Action* ActionManager::getActionByTag(int tag, const Object *target) const
{
    CCASSERT(tag != Action::INVALID_TAG, "");

    tHashElement *element = NULL;
    HASH_FIND_PTR(m_pTargets, &target, element);

    if (element)
    {
        if (element->actions != NULL)
        {
            long limit = element->actions->num;
            for (long i = 0; i < limit; ++i)
            {
                Action *action = (Action*)element->actions->arr[i];

                if (action->getTag() == (int)tag)
                {
                    return action;
                }
            }
        }
        CCLOG("cocos2d : getActionByTag(tag = %d): Action not found", tag);
    }
    else
    {
        // CCLOG("cocos2d : getActionByTag: Target not found");
    }

    return NULL;
}
开发者ID:mcodegeeks,项目名称:OpenKODE-Framework,代码行数:33,代码来源:CCActionManager.cpp


示例7: HASH_FIND_PTR

void ActionManager::removeAllActionsFromTarget(Object *target)
{
    // explicit null handling
    if (target == NULL)
    {
        return;
    }

    tHashElement *element = NULL;
    HASH_FIND_PTR(m_pTargets, &target, element);
    if (element)
    {
        if (ccArrayContainsObject(element->actions, element->currentAction) && (! element->currentActionSalvaged))
        {
            element->currentAction->retain();
            element->currentActionSalvaged = true;
        }

        ccArrayRemoveAllObjects(element->actions);
        if (m_pCurrentTarget == element)
        {
            m_bCurrentTargetSalvaged = true;
        }
        else
        {
            deleteHashElement(element);
        }
    }
    else
    {
//        CCLOG("cocos2d: removeAllActionsFromTarget: Target not found");
    }
}
开发者ID:mcodegeeks,项目名称:OpenKODE-Framework,代码行数:33,代码来源:CCActionManager.cpp


示例8: rvmRegisterReference

void rvmRegisterReference(Env* env, Object* reference, Object* referent) {
    if (referent) {
        // Add 'reference' to the references list for 'referent' in the referents hashtable
        rvmLockMutex(&referentsLock);

        ReferenceList* l = rvmAllocateMemory(env, sizeof(ReferenceList));
        if (!l) goto done; // OOM thrown
        l->reference = reference;

        void* key = (void*) GC_HIDE_POINTER(referent); // Hide the pointer from the GC so that it doesn't prevent the referent from being GCed.
        ReferentEntry* referentEntry;
        HASH_FIND_PTR(referents, &key, referentEntry);
        if (!referentEntry) {
            // referent is not in the hashtable. Add it.
            referentEntry = rvmAllocateMemory(env, sizeof(ReferentEntry));
            if (!referentEntry) goto done; // OOM thrown
            referentEntry->key = key;
            HASH_ADD_PTR(referents, key, referentEntry);
        }

        // Add the reference to the referent's list of references
        LL_PREPEND(referentEntry->references, l);

        // Register the referent for finalization
        GC_REGISTER_FINALIZER_NO_ORDER(referent, _finalizeObject, NULL, NULL, NULL);

done:
        rvmUnlockMutex(&referentsLock);
    }
}
开发者ID:TimurTarasenko,项目名称:robovm,代码行数:30,代码来源:memory.c


示例9: CCASSERT

void ActionManager::removeAllActionsByTag(int tag, Node *target)
{
    CCASSERT(tag != Action::INVALID_TAG, "Invalid tag value!");
    CCASSERT(target != nullptr, "target can't be nullptr!");
    if (target == nullptr)
    {
        return;
    }
    
    tHashElement *element = nullptr;
    HASH_FIND_PTR(_targets, &target, element);
    
    if (element)
    {
        auto limit = element->actions->num;
        for (int i = 0; i < limit;)
        {
            Action *action = (Action*)element->actions->arr[i];
            
            if (action->getTag() == (int)tag && action->getOriginalTarget() == target)
            {
                removeActionAtIndex(i, element);
                --limit;
            }
            else
            {
                ++i;
            }
        }
    }
}
开发者ID:602147629,项目名称:PlanetWar,代码行数:31,代码来源:CCActionManager.cpp


示例10: CCASSERT

// FIXME: Passing "const O *" instead of "const O&" because HASH_FIND_IT requries the address of a pointer
// and, it is not possible to get the address of a reference
Action* ActionManager::getActionByTag(int tag, const Node *target) const
{
    CCASSERT(tag != Action::INVALID_TAG, "");

    tHashElement *element = nullptr;
    HASH_FIND_PTR(_targets, &target, element);

    if (element)
    {
        if (element->actions != nullptr)
        {
            auto limit = element->actions->num;
            for (int i = 0; i < limit; ++i)
            {
                Action *action = (Action*)element->actions->arr[i];

                if (action->getTag() == (int)tag)
                {
                    return action;
                }
            }
        }
        //CCLOG("cocos2d : getActionByTag(tag = %d): Action not found", tag);
    }
    else
    {
        // CCLOG("cocos2d : getActionByTag: Target not found");
    }

    return nullptr;
}
开发者ID:TheWindShan,项目名称:HYFish,代码行数:33,代码来源:CCActionManager.cpp


示例11: HASH_FIND_PTR

void ActionManager::removeAllActionsFromTarget(Node *target)
{
    // explicit null handling
    if (target == nullptr)
    {
        return;
    }

    tHashElement *element = nullptr;
    HASH_FIND_PTR(_targets, &target, element);
    if (element)
    {
        if (ccArrayContainsObject(element->actions, element->currentAction) && (! element->currentActionSalvaged))
        {
            element->currentAction->retain();
            element->currentActionSalvaged = true;
        }

        ccArrayRemoveAllObjects(element->actions);
        if (_currentTarget == element)
        {
            _currentTargetSalvaged = true;
        }
        else
        {
            deleteHashElement(element);
        }
    }
}
开发者ID:602147629,项目名称:PlanetWar,代码行数:29,代码来源:CCActionManager.cpp


示例12: debug_alloc_find

void *
debug_alloc_find (void *a)
{
    alloc_table_t *at = NULL;   /* entry corresponding to "a" */

    HASH_FIND_PTR (atp, &a, at);
    return at;
}
开发者ID:jdinan,项目名称:openshmem,代码行数:8,代码来源:debug_alloc.c


示例13: finalizeObject

static void finalizeObject(Env* env, Object* obj) {
//    TRACEF("finalizeObject: %p (%s)\n", obj, obj->clazz->name);

    rvmLockMutex(&referentsLock);
    void* key = (void*) GC_HIDE_POINTER(obj);
    ReferentEntry* referentEntry;
    HASH_FIND_PTR(referents, &key, referentEntry);

    assert(referentEntry != NULL);

    if (referentEntry->references == NULL) {
        // The object is not referenced by any type of reference and can never be resurrected.
        HASH_DEL(referents, referentEntry);
        rvmUnlockMutex(&referentsLock);
        return;
    }

    Object* softReferences = NULL;
    Object* weakReferences = NULL;
    Object* finalizerReferences = NULL;
    Object* phantomReferences = NULL;
    Object* clearedReferences = NULL;

    ReferenceList* refNode;
    while (referentEntry->references != NULL) {
        refNode = referentEntry->references;
        LL_DELETE(referentEntry->references, refNode);
        Object** list = NULL;
        Object* reference = refNode->reference;
        if (rvmIsSubClass(java_lang_ref_SoftReference, reference->clazz)) {
            list = &softReferences;
        } else if (rvmIsSubClass(java_lang_ref_WeakReference, reference->clazz)) {
            list = &weakReferences;
        } else if (rvmIsSubClass(java_lang_ref_FinalizerReference, reference->clazz)) {
            list = &finalizerReferences;
        } else if (rvmIsSubClass(java_lang_ref_PhantomReference, reference->clazz)) {
            list = &phantomReferences;
        }
        enqueuePendingReference(env, reference, list);
    }
    assert(referentEntry->references == NULL);

    clearAndEnqueueReferences(env, &softReferences, &clearedReferences);
    clearAndEnqueueReferences(env, &weakReferences, &clearedReferences);
    enqueueFinalizerReferences(env, &finalizerReferences, &clearedReferences);
    clearAndEnqueueReferences(env, &phantomReferences, &clearedReferences);

    // Reregister for finalization. If no new references have been added to the list of references for the referent the
    // next time it gets finalized we know it will never be resurrected.
    GC_REGISTER_FINALIZER_NO_ORDER(obj, _finalizeObject, NULL, NULL, NULL);

    rvmUnlockMutex(&referentsLock);

    if (clearedReferences != NULL) {
        rvmCallVoidClassMethod(env, java_lang_ref_ReferenceQueue, java_lang_ref_ReferenceQueue_add, clearedReferences);
        assert(rvmExceptionOccurred(env) == NULL);
    }
}
开发者ID:TimurTarasenko,项目名称:robovm,代码行数:58,代码来源:memory.c


示例14: jsb_get_proxy_for_jsobject

// Hash of JSObject -> proxy
void* jsb_get_proxy_for_jsobject(JSObject *obj)
{
	tHashJSObject *element = NULL;
	HASH_FIND_PTR(hash, &obj, element);
	
	if( element )
		return element->proxy;
	return NULL;
}
开发者ID:12white,项目名称:CocoStudioSamples,代码行数:10,代码来源:js_bindings_core.cpp


示例15: jsb_del_proxy_for_jsobject

void jsb_del_proxy_for_jsobject(JSObject *obj)
{
	tHashJSObject *element = NULL;
	HASH_FIND_PTR(hash, &obj, element);
	if( element ) {		
		HASH_DEL(hash, element);
		free(element);
	}
}
开发者ID:12white,项目名称:CocoStudioSamples,代码行数:9,代码来源:js_bindings_core.cpp


示例16: jsb_del_jsobject_for_proxy

void jsb_del_jsobject_for_proxy(void* proxy)
{
	tHashJSObject *element = NULL;
	HASH_FIND_PTR(reverse_hash, &proxy, element);
	if( element ) {		
		HASH_DEL(reverse_hash, element);
		free(element);
	}	
}
开发者ID:12white,项目名称:CocoStudioSamples,代码行数:9,代码来源:js_bindings_core.cpp


示例17: jsb_get_jsobject_for_proxy

// Reverse hash: Proxy -> JSObject
JSObject* jsb_get_jsobject_for_proxy(void *proxy)
{
	tHashJSObject *element = NULL;
	HASH_FIND_PTR(reverse_hash, &proxy, element);
	
	if( element )
		return element->jsObject;
	return NULL;
}
开发者ID:12white,项目名称:CocoStudioSamples,代码行数:10,代码来源:js_bindings_core.cpp


示例18: xpl_free

void xpl_free(void *ptr) {
    xpl_allocation_t *allocation_info = NULL;
    HASH_FIND_PTR(allocations, &ptr, allocation_info);

    if (allocation_info == NULL) {
        LOG_ERROR("Double-free detected %p (allocation table entry not found)", ptr);

        xpl_allocation_t *found, *tmp;
        LOG_DEBUG("Table:");
        HASH_ITER(hh, allocations, found, tmp) {
            LOG_DEBUG("> %p     %lu bytes", found->handle, (unsigned long)found->bytes);
        }
开发者ID:justinbowes,项目名称:ld26,代码行数:12,代码来源:xpl_memory.c


示例19: getReferentEntryForObject

/**
 * Returns the ReferentEntry for the specified object or creates one and adds
 * it to the referents hash if none exists. referentsLock MUST be held.
 */
static ReferentEntry* getReferentEntryForObject(Env* env, Object* o) {
    void* key = (void*) GC_HIDE_POINTER(o); // Hide the pointer from the GC so that the key doesn't prevent the object from being GCed.
    ReferentEntry* referentEntry;
    HASH_FIND_PTR(referents, &key, referentEntry);
    if (!referentEntry) {
        // Object is not in the hashtable. Add it.
        referentEntry = allocateMemoryOfKind(env, sizeof(ReferentEntry), referentEntryGCKind);
        if (!referentEntry) return NULL; // OOM thrown
        referentEntry->key = key;
        HASH_ADD_PTR(referents, key, referentEntry);
    }
    return referentEntry;
}
开发者ID:tobium,项目名称:robovm,代码行数:17,代码来源:memory.c


示例20: retreive_size

size_t retreive_size(void *someaddr){
  size_t res;
  hash_t *elem = NULL;
  HASH_FIND_PTR(size_hash, &someaddr, elem);
  if(!elem){
    fprintf(stderr,"cannot find ptr %p to free!\n",someaddr);
    return 0;
  }

  res  = elem->size;
  if(get_verbose_level()>=DEBUG)
    printf("Retreiving (%p,%ld)\n",someaddr, res);

  HASH_DEL( size_hash, elem);
  return res;
}
开发者ID:abouteiller,项目名称:ompi-aurelien,代码行数:16,代码来源:tm_malloc.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ HASH_FIND_STR函数代码示例发布时间:2022-05-30
下一篇:
C++ HASH_FIND_INT函数代码示例发布时间: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