Memory Allocation Subsystem … More...
Functions | |
static void | Sq3Free (MK_PTR N) |
Memory Allocation Subsystem … | |
static MK_PTR | Sq3Malloc (MK_I32 N) |
Memory Allocation Subsystem … | |
static MK_PTR | Sq3Malloc64 (MK_I64 N) |
Memory Allocation Subsystem … | |
static MK_I64 | Sq3Msize (MK_PTR N) |
Memory Allocation Subsystem … | |
static MK_PTR | Sq3Realloc (MK_PTR arg0, MK_I32 N) |
Memory Allocation Subsystem … | |
static MK_PTR | Sq3Realloc64 (MK_PTR arg0, MK_I64 N) |
Memory Allocation Subsystem … | |
Sq3Lite - Sq3Lite_Internal_Alloc_C_API - function | |
void | Sq3FreeP (MK_PTR N) |
Non-inline replacement for Sq3Free … | |
MK_PTR | Sq3MallocP (MK_I32 N) |
Non-inline replacement for Sq3Malloc … | |
MK_PTR | Sq3Malloc64P (MK_I64 N) |
Non-inline replacement for Sq3Malloc64 … | |
MK_I64 | Sq3MsizeP (MK_PTR N) |
Non-inline replacement for Sq3Msize … | |
MK_PTR | Sq3ReallocP (MK_PTR arg0, MK_I32 N) |
Non-inline replacement for Sq3Realloc … | |
MK_PTR | Sq3Realloc64P (MK_PTR arg0, MK_I64 N) |
Non-inline replacement for Sq3Realloc64 … | |
Memory Allocation Subsystem …
The SQLite core uses these three routines for all of its own internal memory allocation needs. "Core" in the previous sentence does not include operating-system specific VFS implementation. The Windows VFS uses native malloc() and free() for some operations.
The Sq3Malloc() routine returns a pointer to a block of memory at least N bytes in length, where N is the parameter. If Sq3Malloc() is unable to obtain sufficient free memory, it returns a NULL pointer. If the parameter N to Sq3Malloc() is zero or negative then Sq3Malloc() returns a NULL pointer.
The Sq3Malloc64(N) routine works just like Sq3Malloc(N) except that N is an unsigned 64-bit integer instead of a signed 32-bit integer.
Calling Sq3Free() with a pointer previously returned by Sq3Malloc() or Sq3Realloc() releases that memory so that it might be reused. The Sq3Free() routine is a no-op if is called with a NULL pointer. Passing a NULL pointer to Sq3Free() is harmless. After being freed, memory should neither be read nor written. Even reading previously freed memory might result in a segmentation fault or other severe error. Memory corruption, a segmentation fault, or other severe error might result if Sq3Free() is called with a non-NULL pointer that was not obtained from Sq3Malloc() or Sq3Realloc().
The Sq3Realloc(X,N) interface attempts to resize a prior memory allocation X to be at least N bytes. If the X parameter to Sq3Realloc(X,N) is a NULL pointer then its behavior is identical to calling Sq3Malloc(N). If the N parameter to Sq3Realloc(X,N) is zero or negative then the behavior is exactly the same as calling Sq3Free(X). Sq3Realloc(X,N) returns a pointer to a memory allocation of at least N bytes in size or NULL if insufficient memory is available. If M is the size of the prior allocation, then min(N,M) bytes of the prior allocation are copied into the beginning of buffer returned by Sq3Realloc(X,N) and the prior allocation is freed. If Sq3Realloc(X,N) returns NULL and N is positive, then the prior allocation is not freed.
The Sq3Realloc64(X,N) interfaces works the same as Sq3Realloc(X,N) except that N is a 64-bit unsigned integer instead of a 32-bit signed integer.
If X is a memory allocation previously obtained from Sq3Malloc(), Sq3Malloc64(), Sq3Realloc(), or Sq3Realloc64(), then Sq3Msize(X) returns the size of that memory allocation in bytes. The value returned by Sq3Msize(X) might be larger than the number of bytes requested when X was allocated. If X is a NULL pointer then Sq3Msize(X) returns zero. If X points to something that is not the beginning of memory allocation, or if it points to a formerly valid memory allocation that has now been freed, then the behavior of Sq3Msize(X) is undefined and possibly harmful.
The memory returned by Sq3Malloc(), Sq3Realloc(), Sq3Malloc64(), and Sq3Realloc64() 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.
The pointer arguments to Sq3Free () and Sq3Realloc () must be either NULL or else pointers obtained from a prior invocation of Sq3Malloc () or Sq3Realloc () 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 Sq3Free () or Sq3Realloc ().
Reference code from sqlite3:
|
inlinestatic |
Memory Allocation Subsystem …
read more at 'Sq3Lite_Internal_Alloc_C_API'
Definition at line 765 of file LibSq3Lite_sq3.h.
Memory Allocation Subsystem …
read more at 'Sq3Lite_Internal_Alloc_C_API'
Definition at line 770 of file LibSq3Lite_sq3.h.
Memory Allocation Subsystem …
read more at 'Sq3Lite_Internal_Alloc_C_API'
Definition at line 775 of file LibSq3Lite_sq3.h.
Non-inline replacement for Sq3Malloc64 …
Memory Allocation Subsystem …
read more at 'Sq3Lite_Internal_Alloc_C_API'
Definition at line 780 of file LibSq3Lite_sq3.h.
Memory Allocation Subsystem …
read more at 'Sq3Lite_Internal_Alloc_C_API'
Definition at line 785 of file LibSq3Lite_sq3.h.
Memory Allocation Subsystem …
read more at 'Sq3Lite_Internal_Alloc_C_API'
Definition at line 790 of file LibSq3Lite_sq3.h.
Non-inline replacement for Sq3Realloc64 …
Non-inline replacement for Sq3Realloc …