Back to Mimalloc

mi

docs/group__typed.html

3.5.06.1 KB
Original Source

| | mi-malloc 3.4/2.4/1.9 | |

Loading...

Searching...

No Matches

Macros

Typed Macros

Typed allocation macros. More...

|

Macros

| | #define | mi_malloc_tp(tp) | | | Allocate a block of type tp.
| | | | #define | mi_free_tp(tp, p) | | | Free an object of type tp.
| | | | #define | mi_zalloc_tp(tp) | | | Allocate a zero-initialized block of type tp.
| | | | #define | mi_calloc_tp(tp, count) | | | Allocate count zero-initialized blocks of type tp.
| | | | #define | mi_mallocn_tp(tp, count) | | | Allocate count blocks of type tp.
| | | | #define | mi_reallocn_tp(p, tp, count) | | | Re-allocate to count blocks of type tp.
| | | | #define | mi_heap_malloc_tp(tp, hp) | | | Allocate a block of type tp in a heap hp.
| | | | #define | mi_heap_zalloc_tp(tp, hp) | | | Allocate a zero-initialized block of type tp in a heap hp.
| | | | #define | mi_heap_calloc_tp(tp, hp, count) | | | Allocate count zero-initialized blocks of type tp in a heap hp.
| | | | #define | mi_heap_mallocn_tp(tp, hp, count) | | | Allocate count blocks of type tp in a heap hp.
| | | | #define | mi_heap_reallocn_tp(tp, hp, p, count) | | | Re-allocate to count blocks of type tp in a heap hp.
| | | | #define | mi_heap_recalloc_tp(tp, hp, p, count) | | | Re-allocate to count zero initialized blocks of type tp in a heap hp.
| | |

Detailed Description

Typed allocation macros.

For example:

int* p = mi_malloc_tp(int)

mi_malloc_tp

#define mi_malloc_tp(tp)

Allocate a block of type tp.

Definition mimalloc-doc.h:364

On v3 these can improve performance as they use the mi_<malloc>_csize api's that in turn can use mi_malloc_small(), mi_free_small(), etc.

Macro Definition Documentation

mi_calloc_tp

| #define mi_calloc_tp | ( | | tp, | | | | | count ) |

Allocate count zero-initialized blocks of type tp.

mi_free_tp

| #define mi_free_tp | ( | | tp, | | | | | p ) |

Free an object of type tp.

Parameters

| tp | The type of the object that is freed. | | p | A pointer to an object of type tp (or NULL ) Can be more efficient as it internally uses mi_free_csize() |

See alsomi_free_csize() mi_free_small()

mi_heap_calloc_tp

| #define mi_heap_calloc_tp | ( | | tp, | | | | | hp, | | | | | count ) |

Allocate count zero-initialized blocks of type tp in a heap hp.

mi_heap_malloc_tp

| #define mi_heap_malloc_tp | ( | | tp, | | | | | hp ) |

Allocate a block of type tp in a heap hp.

mi_heap_mallocn_tp

| #define mi_heap_mallocn_tp | ( | | tp, | | | | | hp, | | | | | count ) |

Allocate count blocks of type tp in a heap hp.

mi_heap_reallocn_tp

| #define mi_heap_reallocn_tp | ( | | tp, | | | | | hp, | | | | | p, | | | | | count ) |

Re-allocate to count blocks of type tp in a heap hp.

mi_heap_recalloc_tp

| #define mi_heap_recalloc_tp | ( | | tp, | | | | | hp, | | | | | p, | | | | | count ) |

Re-allocate to count zero initialized blocks of type tp in a heap hp.

mi_heap_zalloc_tp

| #define mi_heap_zalloc_tp | ( | | tp, | | | | | hp ) |

Allocate a zero-initialized block of type tp in a heap hp.

mi_malloc_tp

| #define mi_malloc_tp | ( | | tp | ) | |

Allocate a block of type tp.

Parameters

| tp | The type of the block to allocate. |

ReturnsA pointer to an object of type tp, or NULL if out of memory.

Example:

int* p = mi_malloc_tp(int)

Using this is more safe, but can also be more efficient since the allocation size is a compile-time constant.

See alsomi_malloc_csize() mi_malloc_small()

mi_mallocn_tp

| #define mi_mallocn_tp | ( | | tp, | | | | | count ) |

Allocate count blocks of type tp.

mi_reallocn_tp

| #define mi_reallocn_tp | ( | | p, | | | | | tp, | | | | | count ) |

Re-allocate to count blocks of type tp.

mi_zalloc_tp

| #define mi_zalloc_tp | ( | | tp | ) | |

Allocate a zero-initialized block of type tp.

  • Generated by 1.11.0