Guardedalloc: Add extra logging and checks in MEM_freeN()
We don't like when NULL is send to MEM_freeN(), but there was some differences between lockfree and guarded allocators: - Lockfree would have silently crash, in both release and debug modes - Guarded allocator would have printed error message, abort in debug but keep working in release build. This commit makes lockfree allocator behavior to match guarded one.
This commit is contained in:
parent
0f2adc0817
commit
6c5f63b476
|
@ -17,6 +17,7 @@
|
|||
*
|
||||
* Contributor(s): Brecht Van Lommel
|
||||
* Campbell Barton
|
||||
* Sergey Sharybin
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
*/
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
*
|
||||
* Contributor(s): Brecht Van Lommel
|
||||
* Campbell Barton
|
||||
* Sergey Sharybin
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
*/
|
||||
|
|
|
@ -134,6 +134,14 @@ void MEM_lockfree_freeN(void *vmemh)
|
|||
MemHead *memh = MEMHEAD_FROM_PTR(vmemh);
|
||||
size_t len = MEM_lockfree_allocN_len(vmemh);
|
||||
|
||||
if (vmemh == NULL) {
|
||||
print_error("Attempt to free NULL pointer\n");
|
||||
#ifdef WITH_ASSERT_ABORT
|
||||
abort();
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
atomic_sub_u(&totblock, 1);
|
||||
atomic_sub_z(&mem_in_use, len);
|
||||
|
||||
|
|
Loading…
Reference in New Issue