当前位置: 首页 > news >正文

网站备案协议五莲做网站

网站备案协议,五莲做网站,电脑什么网站可以做长图攻略,建设网站公司哪好源代码在这里下载 来到malloc/malloc.c 在980行发现这段代码 // 定义最大 mmap 值为 -4 #define M_MMAP_MAX -4// 如果没有定义 DEFAULT_MMAP_MAX#xff0c;则将其定义为 65536 #ifndef DEFAULT_MMAP_MAX #define DEFAULT_MMAP_MAX (65536) #endif// 引…源代码在这里下载 来到malloc/malloc.c 在980行发现这段代码 // 定义最大 mmap 值为 -4 #define M_MMAP_MAX -4// 如果没有定义 DEFAULT_MMAP_MAX则将其定义为 65536 #ifndef DEFAULT_MMAP_MAX #define DEFAULT_MMAP_MAX (65536) #endif// 引入 malloc.h 头文件通常包含内存分配和释放相关的函数声明 #include malloc.h// 如果没有定义 RETURN_ADDRESS 宏定义为一个空操作返回 NULL #ifndef RETURN_ADDRESS #define RETURN_ADDRESS(X_) (NULL) #endif/* 结构体和类型的前向声明 */// 定义 malloc_chunk 结构体实际定义可能在代码的其他地方 struct malloc_chunk;// 定义 mchunkptr 为指向 malloc_chunk 结构体的指针类型 typedef struct malloc_chunk* mchunkptr;/* 内部函数声明 */// 内部函数分配内存 static void* _int_malloc(mstate, size_t);// 内部函数释放内存 static void _int_free(mstate, mchunkptr, int);// 内部函数调整内存块大小 static void* _int_realloc(mstate, mchunkptr, INTERNAL_SIZE_T, INTERNAL_SIZE_T);// 内部函数内存对齐分配 static void* _int_memalign(mstate, size_t, size_t);// 内部函数内存对齐分配的中间实现 static void* _mid_memalign(size_t, size_t, void *);// 内部函数打印内存分配错误信息且该函数不会返回 static void malloc_printerr(const char *str) __attribute__ ((noreturn));// 内部函数检查内存块的有效性 static void* mem2mem_check(void *p, size_t sz);// 内部函数检查堆的顶端是否正常 static void top_check(void);// 内部函数通过 munmap 释放内存块 static void munmap_chunk(mchunkptr p);// 如果系统支持 mremap则声明 mremap_chunk 函数用于调整内存映射 #if HAVE_MREMAP static mchunkptr mremap_chunk(mchunkptr p, size_t new_size); #endif// 内部函数检查 malloc 操作的合法性 static void* malloc_check(size_t sz, const void *caller);// 内部函数检查 free 操作的合法性 static void free_check(void* mem, const void *caller);// 内部函数检查 realloc 操作的合法性 static void* realloc_check(void* oldmem, size_t bytes, const void *caller);// 内部函数检查内存对齐分配操作的合法性 static void* memalign_check(size_t alignment, size_t bytes, const void *caller);查看malloc_chunk结构体 // 定义内存块的元数据结构体用于管理堆中的内存块 struct malloc_chunk {INTERNAL_SIZE_T mchunk_prev_size; // 前一个内存块的大小如果该块是空闲的INTERNAL_SIZE_T mchunk_size; // 当前内存块的大小包括元数据的开销// 双向链表指针用于空闲内存块的链表管理struct malloc_chunk* fd; // 指向下一个空闲块的指针free list 链表的正向指针struct malloc_chunk* bk; // 指向上一个空闲块的指针free list 链表的反向指针// 只用于较大的内存块指向比当前内存块大的下一个内存块struct malloc_chunk* fd_nextsize; // 双向链表指针用于管理按大小排列的空闲块struct malloc_chunk* bk_nextsize; // 双向链表指针指向下一个比当前块大的空闲块};在下面还能看到关于堆结构的注释 /*malloc_chunk details:(The following includes lightly edited explanations by Colin Plumb.)Chunks of memory are maintained using a boundary tag method asdescribed in e.g., Knuth or Standish. (See the paper by PaulWilson ftp://ftp.cs.utexas.edu/pub/garbage/allocsrv.ps for asurvey of such techniques.) Sizes of free chunks are stored bothin the front of each chunk and at the end. This makesconsolidating fragmented chunks into bigger chunks very fast. Thesize fields also hold bits representing whether chunks are free orin use.An allocated chunk looks like this:chunk- --------------------------------| Size of previous chunk, if unallocated (P clear) |--------------------------------| Size of chunk, in bytes |A|M|P|mem- --------------------------------| User data starts here... .. .. (malloc_usable_size() bytes) .. | nextchunk- --------------------------------| (size of chunk, but used for application data) |--------------------------------| Size of next chunk, in bytes |A|0|1|--------------------------------Where chunk is the front of the chunk for the purpose of most ofthe malloc code, but mem is the pointer that is returned to theuser. Nextchunk is the beginning of the next contiguous chunk.Chunks always begin on even word boundaries, so the mem portion(which is returned to the user) is also on an even word boundary, andthus at least double-word aligned.Free chunks are stored in circular doubly-linked lists, and look like this:chunk- --------------------------------| Size of previous chunk, if unallocated (P clear) |--------------------------------head: | Size of chunk, in bytes |A|0|P|mem- --------------------------------| Forward pointer to next chunk in list |--------------------------------| Back pointer to previous chunk in list |--------------------------------| Unused space (may be 0 bytes long) .. .. | nextchunk- --------------------------------foot: | Size of chunk, in bytes |--------------------------------| Size of next chunk, in bytes |A|0|0|--------------------------------The P (PREV_INUSE) bit, stored in the unused low-order bit of thechunk size (which is always a multiple of two words), is an in-usebit for the *previous* chunk. If that bit is *clear*, then theword before the current chunk size contains the previous chunksize, and can be used to find the front of the previous chunk.The very first chunk allocated always has this bit set,preventing access to non-existent (or non-owned) memory. Ifprev_inuse is set for any given chunk, then you CANNOT determinethe size of the previous chunk, and might even get a memoryaddressing fault when trying to do so.The A (NON_MAIN_ARENA) bit is cleared for chunks on the initial,main arena, described by the main_arena variable. When additionalthreads are spawned, each thread receives its own arena (up to aconfigurable limit, after which arenas are reused for multiplethreads), and the chunks in these arenas have the A bit set. Tofind the arena for a chunk on such a non-main arena, heap_for_ptrperforms a bit mask operation and indirection through the ar_ptrmember of the per-heap header heap_info (see arena.c).Note that the foot of the current chunk is actually representedas the prev_size of the NEXT chunk. This makes it easier todeal with alignments etc but can be very confusing when tryingto extend or adapt this code.The three exceptions to all this are:1. The special chunk top doesnt bother using thetrailing size field since there is no next contiguous chunkthat would have to index off it. After initialization, topis forced to always exist. If it would become less thanMINSIZE bytes long, it is replenished.2. Chunks allocated via mmap, which have the second-lowest-orderbit M (IS_MMAPPED) set in their size fields. Because they areallocated one-by-one, each must contain its own trailing sizefield. If the M bit is set, the other bits are ignored(because mmapped chunks are neither in an arena, nor adjacentto a freed chunk). The M bit is also used for chunks whichoriginally came from a dumped heap via malloc_set_state inhooks.c.3. Chunks in fastbins are treated as allocated chunks from thepoint of view of the chunk allocator. They are consolidatedwith their neighbors only in bulk, in malloc_consolidate. */翻译并整理后 malloc_chunk 详细信息 以下内容包含由 Colin Plumb 轻微编辑的解释。 内存块是通过一种 边界标签 方法来管理的如 Knuth 或 Standish 所述。有关此类技术的概述请参见 Paul Wilson 的论文ftp://ftp.cs.utexas.edu/pub/garbage/allocsrv.ps。空闲块的大小会同时存储在每个块的前面和后面。这使得将碎片化的块合并为更大的块非常快速。大小字段还包含表示块是空闲还是正在使用的位。 分配的块结构 一个已分配的内存块如下所示 以下是转换为中文Markdown表格的格式 位置内容说明chunk-前一个块的大小当P标志清除时表示未分配当前块的大小字节数|A|M|P|mem-用户数据起始位置可用内存大小malloc_usable_size()字节nextchunk-块的大小但用于应用程序数据下一个块的大小字节数|A|0|1| 其中chunk 是块的前端用于大部分 malloc 代码但 mem 是返回给用户的指针。nextchunk 是下一个连续块的开始。块总是以偶数字边界开始因此返回给用户的 mem 部分也会以偶数字边界开始从而至少是双字对齐的。 空闲块结构 空闲块存储在循环双向链表中结构如下 以下是转换为中文Markdown表格的格式 位置内容说明chunk-前一个块的大小当P标志清除时表示未分配‘head:’当前块的大小字节数|A|0|P|mem-指向列表中下一个块的前向指针指向列表中前一个块的后向指针未使用空间可能长度为0字节nextchunk-‘foot:’当前块的大小字节数下一个块的大小字节数|A|0|0| 关键位说明 PPREV_INUSE位存储在块大小的低位总是一个双字的倍数表示前一个块是否正在使用。如果该位清除则当前块之前的字包含前一个块的大小可用来找到前一个块的前端。分配的第一个块总是将此位设置为 1防止访问不存在的或未拥有的内存。如果某个块的 prev_inuse 位设置则无法确定前一个块的大小甚至在尝试访问时可能会引发内存访问错误。 ANON_MAIN_ARENA位该位在初始的主 arena 中清除在由 main_arena 变量描述的 arena 中的块中。如果分配了额外的线程每个线程会获得自己的 arena直到达到可配置的限制之后多个线程共享相同的 arena。这些 arena 中的块会将 A 位设置为 1。要查找这种非主 arena 中的块所在的 arenaheap_for_ptr 通过位掩码操作和 heap_info 中每个堆头部的 ar_ptr 成员进行间接访问详见 arena.c。 特殊情况 当前块的 foot 实际上表示的是下一个块的 prev_size。这种设计使得对齐处理更简便但在尝试扩展或适应代码时可能会非常困惑。 三个特殊情况 特殊块 top由于没有下一个连续块需要索引因此 top 块不使用尾部的大小字段。在初始化后top 块必须始终存在。如果它变得小于 MINSIZE 字节它会被补充。 通过 mmap 分配的块这些块在其大小字段中设置了次低位的 MIS_MMAPPED位。由于它们是逐一分配的因此每个块必须包含自己的尾部大小字段。如果 M 位设置则其他位会被忽略因为 mmap 分配的块既不在 arena 中也不与空闲块相邻。M 位也用于那些最初来自转储堆并通过 malloc_set_state 恢复的块见 hooks.c。 快速分配区的块从块分配器的角度来看快速分配区的块被视为已分配的块。它们只在 malloc_consolidate 中与相邻块进行合并而不是逐块合并。
http://www.hkea.cn/news/14378536/

相关文章:

  • 东莞市建设网站首页官网《php网站开发》电子课件
  • 长沙有哪些网站建设公司网站建设的过程
  • 公司做网站需要准备什么资料个人网站被黑了
  • 小型购物网站开发费用百度首页排名优化服务
  • 网站要咋做网站做抢红包活动广告语
  • 网站开发按钮图片素材建设公司起名大全字库
  • 举出最新的网络营销的案例聊城网站优化
  • 怎么做网站链接广告如何做一个好的wordpress
  • 上线吧做的网站可以备案企业邮箱认证怎么弄
  • 做内贸的网站网站雪花代码
  • 如何做基金公司网站百度搜到自己网站
  • 做电影网站主机放哪比较好网站开发所需要的书籍
  • 阅读网站怎么做网站推广是网站建设完成之后的长期工作。
  • 公司网站建设属于软件销售网站开发欠款
  • 亚马逊在哪个网站做推广个人网站asp
  • 深圳外贸建站网络推广联客易云服务器可以做网站吗
  • 网站设计与开发的基本步骤包括哪些?wap网站如何制作
  • 网站建设整体方案论文外贸型网站该如何推广
  • 网站索引怎么做深圳工业设计工资
  • 上海网站营销seo哪个网站做医学培训好
  • 做meta分析需注册的网站新买的服务器怎么做网站
  • 三门峡网站建设费用汕头网站建设技术托管
  • jimdo做的网站站酷设计官方网站
  • 群晖wordpress搭建网站信息推广网站点不开的那种怎么做
  • 攀枝花住房和城乡建设厅网站惠民县建设网站
  • 网站编程课程设计心得体会缙云建设局网站
  • 网站建设就业建设营销型网站的要素
  • 找最新游戏做视频网站有哪些济南seo网站排名关键词优化
  • 申请一个app多少钱企业专业搜索引擎优化
  • 句容网站制作哪家好企业信用网站建设