| 61 | == Memory allocation == |
| 62 | |
| 63 | As per [wiki:rfc19_safememalloc RFC 19: Safer memory allocation in GDAL], |
| 64 | you can use VSIMalloc2(x, y) instead of doing CPLMalloc(x * y) or VSIMalloc(x * y). |
| 65 | VSIMalloc2 will detect potential overflows in the multiplication and return a NULL pointer |
| 66 | if it happens. This can be useful in GDAL raster drivers where x and y are |
| 67 | related to the raster dimensions or raster block sizes. Similarly, |
| 68 | VSIMalloc3(x, y, z) can be used as a replacement for CPLMalloc(x * y * z). |
| 69 | |