文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>Dalvik引用表ReferenceTable

Dalvik引用表ReferenceTable

时间:2010-08-20  来源:hunterzy416

数据结构

typedef struct ReferenceTable {

    Object**        table;              /* top of the list */

    Object**        nextEntry;          /* bottom of the list */

 

    int             allocEntries;       /* #of entries we have space for */

    int             maxEntries;         /* max #of entries allowed */

} ReferenceTable;

引用表的存储结构


由于使用的单向链表,因此当添加和删除中间元素的是受,需要移动一整块的数据。不知道为何采用这种算法?

bool dvmRemoveFromReferenceTable(ReferenceTable* pRef, Object** top,

    Object* obj)

{

    Object** ptr;

 

    assert(pRef->table != NULL);

 

    /*

     * Scan from the most-recently-added entry up to the top entry for

     * this frame.

     */

    ptr = dvmFindInReferenceTable(pRef, top, obj);

    if (ptr == NULL)

        return false;

 

    /*

     * Delete the entry.

     */

    pRef->nextEntry--;

    int moveCount = pRef->nextEntry - ptr;

    if (moveCount != 0) {

        /* remove from middle, slide the rest down */

        memmove(ptr, ptr+1, moveCount * sizeof(Object*));

        //LOGV("LREF delete %p, shift %d down\n", obj, moveCount);

    } else {

        /* last entry, falls off the end */

        //LOGV("LREF delete %p from end\n", obj);

    }

 

    return true;

}


相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载