# GrallocFuncs - [Overview](#section859227232165631) - [Summary](#section1937256718165631) - [Data Fields](#pub-attribs) - [Details](#section386149568165631) - [Field](#section419891595165631) - [AllocMem](#a48c1f21c086ead11bcb1a53bbec2d285) - [FlushCache](#ad56665aa0ff48995b5ec72a8095416d8) - [FlushMCache](#aceac1511a490c2ade1e33723d0e20960) - [FreeMem](#af80e6c92c5ba7e2419da27cafe19bcff) - [Mmap](#ab64438d785bc59050cd4f0a759bd531b) - [MmapCache](#a25005370b14ff2a0c860b2272b354e3f) - [Unmap](#a55864e4912348f40dd77584e96ad4647) ## **Overview** **Related Modules:** [Display](Display.md) **Description:** Defines pointers to the memory driver functions. ## **Summary** ## Data Fields

Variable Name

Description

AllocMem )(GrallocBuffer *buffer)

int32_t(*

Allocates memory based on the parameters passed by the GUI.

FreeMem )(GrallocBuffer *buffer)

void(*

Releases memory.

Mmap )(GrallocBuffer *buffer)

void *(*

Maps memory to memory without cache in the process's address space.

MmapCache )(GrallocBuffer *buffer)

void *(*

Maps memory to memory with cache in the process's address space.

Unmap )(GrallocBuffer *buffer)

int32_t(*

Unmaps memory, that is, removes any mappings in the process's address space.

FlushCache )(GrallocBuffer *buffer)

int32_t(*

Flushes data from the cache to memory and invalidates the data in the cache.

FlushMCache )(GrallocBuffer *buffer)

int32_t(*

Flushes data from the cache mapped via Mmap to memory and invalidates the data in the cache.

## **Details** ## **Field ** ## AllocMem ``` int32_t(* GrallocFuncs::AllocMem) ([GrallocBuffer](GrallocBuffer.md) *buffer) ``` **Description:** Allocates memory based on the parameters passed by the GUI. The allocated memory can be classified into shared memory, memory with cache, and memory without cache. **Parameters:**

Name

Description

buffer Indicates the pointer to the buffer of the memory to allocate.
**Returns:** Returns **0** if the operation is successful; returns an error code defined in [DispErrCode](Display.md#ga12a925dadef7573cd74d63d06824f9b0) otherwise. ## FlushCache ``` int32_t(* GrallocFuncs::FlushCache) ([GrallocBuffer](GrallocBuffer.md) *buffer) ``` **Description:** Flushes data from the cache to memory and invalidates the data in the cache. **Parameters:**

Name

Description

buffer Indicates the pointer to the buffer of the cache to flush.
**Returns:** Returns **0** if the operation is successful; returns an error code defined in [DispErrCode](Display.md#ga12a925dadef7573cd74d63d06824f9b0) otherwise. ## FlushMCache ``` int32_t(* GrallocFuncs::FlushMCache) ([GrallocBuffer](GrallocBuffer.md) *buffer) ``` **Description:** Flushes data from the cache mapped via [Mmap](GrallocFuncs.md#ab64438d785bc59050cd4f0a759bd531b) to memory and invalidates the data in the cache. **Parameters:**

Name

Description

buffer Indicates the pointer to the buffer of the cache to flush.
**Returns:** Returns **0** if the operation is successful; returns an error code defined in [DispErrCode](Display.md#ga12a925dadef7573cd74d63d06824f9b0) otherwise. ## FreeMem ``` void(* GrallocFuncs::FreeMem) ([GrallocBuffer](GrallocBuffer.md) *buffer) ``` **Description:** Releases memory. **Parameters:**

Name

Description

buffer Indicates the pointer to the buffer of the memory to release.
## Mmap ``` void*(* GrallocFuncs::Mmap) ([GrallocBuffer](GrallocBuffer.md) *buffer) ``` **Description:** Maps memory to memory without cache in the process's address space. **Parameters:**

Name

Description

buffer Indicates the pointer to the buffer of the memory to map.
**Returns:** Returns the pointer to a valid address if the operation is successful; returns **NULL** otherwise. ## MmapCache ``` void*(* GrallocFuncs::MmapCache) ([GrallocBuffer](GrallocBuffer.md) *buffer) ``` **Description:** Maps memory to memory with cache in the process's address space. **Parameters:**

Name

Description

buffer Indicates the pointer to the buffer of the memory to map.
**Returns:** Returns the pointer to a valid address if the operation is successful; returns **NULL** otherwise. ## Unmap ``` int32_t(* GrallocFuncs::Unmap) ([GrallocBuffer](GrallocBuffer.md) *buffer) ``` **Description:** Unmaps memory, that is, removes any mappings in the process's address space. **Parameters:**

Name

Description

buffer Indicates the pointer to the buffer of the memory to unmap.
**Returns:** Returns **0** if the operation is successful; returns an error code defined in [DispErrCode](Display.md#ga12a925dadef7573cd74d63d06824f9b0) otherwise.