MCPcopy Create free account
hub / github.com/F-Stack/f-stack / trash_ctor

Function trash_ctor

freebsd/vm/uma_dbg.c:66–91  ·  view source on GitHub ↗

* Checks an item to make sure it hasn't been overwritten since it was freed, * prior to subsequent reallocation. * * Complies with standard ctor arg/return */

Source from the content-addressed store, hash-verified

64 * Complies with standard ctor arg/return
65 */
66int
67trash_ctor(void *mem, int size, void *arg, int flags)
68{
69 int cnt;
70 uint32_t *p;
71
72#ifdef DEBUG_MEMGUARD
73 if (is_memguard_addr(mem))
74 return (0);
75#endif
76
77 cnt = size / sizeof(uma_junk);
78
79 for (p = mem; cnt > 0; cnt--, p++)
80 if (*p != uma_junk) {
81#ifdef INVARIANTS
82 panic("Memory modified after free %p(%d) val=%x @ %p\n",
83 mem, size, *p, p);
84#else
85 printf("Memory modified after free %p(%d) val=%x @ %p\n",
86 mem, size, *p, p);
87#endif
88 return (0);
89 }
90 return (0);
91}
92
93/*
94 * Fills an item with predictable garbage

Callers 3

mb_ctor_packFunction · 0.85
trash_finiFunction · 0.85
item_ctorFunction · 0.85

Calls 3

is_memguard_addrFunction · 0.85
panicFunction · 0.50
printfFunction · 0.50

Tested by

no test coverage detected