Help Center

CSQLiteStmt.Mallocmethod

Returns a pointer to a block of memory at least N bytes in length, where N is the parameter.

DatabasesmethodCSQLite.incdoc-orphan
No implementation located. This member is documented, but the source scan found no matching declaration. It is likely declared in a header this scan does not resolve, or provided by a macro.

Syntax

FUNCTION Malloc (BYVAL nBytes AS LONG) AS ANY PTR

Parameters

NameDescription
nBytesThe number of bytes to allocate.

Return value

Pointer to the allocated memory.

Description

Returns a pointer to a block of memory at least N bytes in length, where N is the parameter. If Malloc is unable to obtain sufficient free memory, it returns a NULL pointer. If the parameter nBytes to Malloc is zero or negative then returns a NULL pointer.

Remarks

The memory returned by Malloc and Realloc is always aligned to at least an 8 byte boundary, or to a 4 byte boundary if the SQLITE_4_BYTE_ALIGNED_MALLOC compile-time option is used.

In SQLite version 3.5.0 and 3.5.1, it was possible to define the SQLITE_OMIT_MEMORY_ALLOCATION which would cause the built-in implementation of these functions to be omitted. That capability is no longer provided. Only built-in memory allocators can be used.

Prior to SQLite version 3.7.10, the Windows OS interface layer called the system malloc and free directly when converting filenames between the UTF-8 encoding used by SQLite and whatever filename encoding is used by the particular Windows installation. Memory allocation errors were detected, but they were reported back as SQLITE_CANTOPEN or SQLITE_IOERR rather than SQLITE_NOMEM.

The pointer arguments to Free and Realloc must be either NULL or else pointers obtained from a prior invocation of Malloc or Realloc that have not yet been released.

The application must not read or write any part of a block of memory after it has been released using Free or Realloc.

Reference

  • Include file CSQLite.inc
  • Documented in Databases/CSQLite Class.md
  • Topic: CSQLite Class