|
LAMMP 4.2.0
Lamina High-Precision Arithmetic Library
|
#include <stdarg.h>#include <stddef.h>#include <stdint.h>#include <stdio.h>#include <stdlib.h>#include <string.h>
safe_memory.h 的引用(Include)关系图:
此图展示该文件直接或间接的被哪些文件引用了:结构体 | |
| struct | mem_header |
| Copyright (C) 2026 HJimmyK(Jericho Knox) 更多... | |
宏定义 | |
| #define | ALIGNMENT LAMMP_MAX_ALIGN |
| #define | EXTRA_MEM_PATTERN 0xAA |
| #define | MEM_GUARD 0xDEADBEEFUL |
| #define | MEM_MAGIC 0xDEADBEEFDEADBEEFULL |
| #define | SAFE_APPEND(...) |
函数 | |
| static size_t | align_up (size_t size) |
| static int | check_extra_memory_overflow (mem_header *hdr, void *user_ptr, const char *check_func, int check_line) |
| 检查额外内存区域是否被修改。 | |
| static int | check_memory_block_integrity (mem_header *hdr, void *user_ptr, const char *check_func, int check_line) |
| 检查内存块的完整性(包括头尾和额外内存区域)。 | |
| static void | find_corruption_range (const char *data, unsigned char pattern, size_t len, int *first, int *last, int *count) |
| 找到指定模式的连续内存区域,并记录起始和结束位置。 | |
| static void * | lmmp_alloc_debug (size_t size, const char *func, int line) |
| 调试版 malloc | |
| static void | lmmp_free_debug (void *ptr, const char *func, int line) |
| 调试版 free | |
| static void * | lmmp_realloc_debug (void *ptr, size_t new_size, const char *func, int line) |
| 调试版 realloc | |
| struct mem_header |
Copyright (C) 2026 HJimmyK(Jericho Knox)
This file is part of LAMMP.
LAMMP is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License (LGPL) as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
This program is distributed WITHOUT ANY WARRANTY.
See https://www.gnu.org/licenses/.
在文件 safe_memory.h 第 27 行定义.
mem_header 的协作图:| 成员变量 | ||
|---|---|---|
| size_t | extra_size | |
| const char * | func | |
| uint32_t | guard | |
| int | line | |
| uint64_t | magic | |
| size_t | total_size | |
| size_t | user_size | |
| #define ALIGNMENT LAMMP_MAX_ALIGN |
在文件 safe_memory.h 第 41 行定义.
| #define EXTRA_MEM_PATTERN 0xAA |
在文件 safe_memory.h 第 39 行定义.
| #define MEM_GUARD 0xDEADBEEFUL |
在文件 safe_memory.h 第 38 行定义.
| #define MEM_MAGIC 0xDEADBEEFDEADBEEFULL |
在文件 safe_memory.h 第 37 行定义.
| #define SAFE_APPEND | ( | ... | ) |
|
inlinestatic |
在文件 safe_memory.h 第 43 行定义.
引用了 ALIGNMENT.
被这些函数引用 check_extra_memory_overflow(), lmmp_alloc_debug(), lmmp_free_debug() , 以及 lmmp_realloc_debug().
这是这个函数的调用关系图:
|
inlinestatic |
检查额外内存区域是否被修改。
在文件 safe_memory.h 第 75 行定义.
引用了 align_up(), EXTRA_MEM_PATTERN, mem_header::extra_size, find_corruption_range(), mem_header::func, LAMMP_ERROR_OUT_OF_BOUNDS, LAMMP_MEMORY_MORE_ALLOC_TIMES, mem_header::line, lmmp_abort(), SAFE_APPEND , 以及 mem_header::user_size.
被这些函数引用 check_memory_block_integrity().
函数调用图:
这是这个函数的调用关系图:
|
inlinestatic |
检查内存块的完整性(包括头尾和额外内存区域)。
在文件 safe_memory.h 第 121 行定义.
引用了 check_extra_memory_overflow(), mem_header::guard, LAMMP_ERROR_MEMORY_FREE_FAILURE, lmmp_abort(), mem_header::magic, MEM_GUARD , 以及 MEM_MAGIC.
被这些函数引用 lmmp_free_debug() , 以及 lmmp_realloc_debug().
函数调用图:
这是这个函数的调用关系图:
|
inlinestatic |
找到指定模式的连续内存区域,并记录起始和结束位置。
在文件 safe_memory.h 第 50 行定义.
被这些函数引用 check_extra_memory_overflow().
这是这个函数的调用关系图:调试版 malloc
| size | 要分配的内存大小 |
| func | 分配内存的函数名 |
| line | 分配内存的行号 |
在文件 safe_memory.h 第 147 行定义.
引用了 align_up(), EXTRA_MEM_PATTERN, heap_alloc_func, LAMMP_ERROR_MEMORY_ALLOC_FAILURE, LAMMP_MEMORY_MORE_ALLOC_TIMES, lmmp_abort(), mem_header::magic, MEM_GUARD, MEM_MAGIC , 以及 n.
被这些函数引用 lmmp_realloc_debug().
函数调用图:
这是这个函数的调用关系图:调试版 free
| ptr | 指向要释放的内存块的指针 |
| func | 分配内存的函数名 |
| line | 分配内存的行号 |
在文件 safe_memory.h 第 189 行定义.
引用了 align_up(), check_memory_block_integrity(), heap_free_func , 以及 n.
被这些函数引用 lmmp_realloc_debug().
函数调用图:
这是这个函数的调用关系图:
|
inlinestatic |
调试版 realloc
| ptr | 指向要重新分配的内存块的指针 |
| new_size | 新的内存大小 |
| func | 分配内存的函数名 |
| line | 分配内存的行号 |
在文件 safe_memory.h 第 209 行定义.
引用了 align_up(), check_memory_block_integrity(), LAMMP_ERROR_MEMORY_ALLOC_FAILURE, lmmp_abort(), lmmp_alloc_debug(), lmmp_free_debug() , 以及 n.
函数调用图: