Quantcast
Channel: C#
Viewing all articles
Browse latest Browse all 1853

Mismatched Allocation/Deallocation

$
0
0

Occurs when a deallocation is attempted with a function that is not the logical reflection of the allocator used.

Problem type: Mismatched allocation/deallocation

ID

Code Location

Description

1

Allocation site

Represents the location and associated call stack from which the memory block was allocated.

2

Deallocation site

Represents the location and associated call stack attempting the deallocation.

Example

char *s = (char*)malloc(5);
delete s;

Possible Correction Strategies

Use the appropriate deallocation function to return the memory block to the heap after its last use.

Platform

Memory Allocator

Memory Deallocator

C++ language

new operator

delete operator

new[] operator

delete[] operator

C language

malloc(), calloc(), or realloc()functions

free() function

Fortran language

allocate() function

deallocate() function

Windows* API

Windows* dynamic memory functions such as GlobalAlloc() or LocalAlloc()

Appropriate functions, such as GlobalFree() or LocalFree()


Viewing all articles
Browse latest Browse all 1853

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>