CodeQL library for C/C++
Search

Module Alloc

Import path

import semmle.code.cpp.commons.Alloc

Imports

Allocation

Provides an abstract class for modeling functions and expressions that allocate memory, such as the standard malloc function. To use this QL library, create one or more QL classes extending a class here with a characteristic predicate that selects the functions or expressions you are trying to model. Within that class, override the predicates provided by the abstract class to match the specifics of those functions or expressions. Finally, add a private import statement to Models.qll.

Deallocation

Provides an abstract class for modeling functions and expressions that deallocate memory, such as the standard free function. To use this QL library, create one or more QL classes extending a class here with a characteristic predicate that selects the functions or expressions you are trying to model. Within that class, override the predicates provided by the abstract class to match the specifics of those functions or expressions. Finally, add a private import statement to Models.qll.

cpp

Provides classes and predicates for working with C/C++ code.

Predicates

allocationCall

A call to a library routine that allocates memory.

allocationFunction

A library routine that allocates memory.

freeCall

A call to a library routine that frees memory.

freeFunction

A library routine that frees memory.

isAllocationExpr

Is e some kind of allocation (new, alloc, realloc etc)?

isDeallocationExpr

Is e some kind of deallocation (delete, free, realloc etc)?

isFixedSizeAllocationExpr

Is e some kind of allocation (new, alloc, realloc etc) with a fixed size?

isMemoryManagementExpr

Is e some kind of allocation or deallocation (new, alloc, realloc, delete, free etc)?

isStdLibAllocationExpr

Is e an allocation from stdlib.h (malloc, realloc etc)?