jrtplib3.11.1之 源码分析(一):辅助类

2018-12-02  本文已影响38人  C_GO流媒体后台开发

概述

  1. 编译和安装jrtlib之前需要编译和安装jthread库
  2. jrtplib需要用到jthread中的文件 jmutex和jthread。

jthread库

jthread主要是封装了跨平台的thread类和mutex类,包括:

jrtplib类:

struct MemoryInfo  //内存申请信息
{
    void *ptr;            //内存指针
    size_t size;       //内存大小
    int lineno;        //申请时行号
    char *filename;    //文件名称

    MemoryInfo *next;
};

void *operator new(size_t s,char filename[],int line)   // 用来保存申请内存的信息

void dodelete(void *p)                                                       //删除内存
    class HashElement
    {
    public:
        HashElement(const Element &e,int index):element(e) { hashprev = 0; hashnext = 0; listnext = 0; listprev = 0; hashindex = index; }
        int GetHashIndex()                      { return hashindex; }
        Element &GetElement()                       { return element; }
#ifdef RTPDEBUG
        void Dump()                         { std::cout << "\tHash index " << hashindex << " | Element " << element << std::endl; }
#endif // RTPDEBUG
    private:
        int hashindex;
        Element element;
    public:
        HashElement *hashprev,*hashnext;
        HashElement *listprev,*listnext;
    };
    //数组指针 二维数组   根据key的索引值 包含HashElement的链表 指针
    HashElement *table[hashsize];
    //数据的链表开始和结束
    HashElement *firsthashelem,*lasthashelem;
    //当前项 查找 删除时使用
    HashElement *curhashelem;

参考

jrtplib 源码分析 (一) 辅助类

上一篇 下一篇

猜你喜欢

热点阅读