# NNS_GfdAllocPlttVram

## Syntax

      #include <nnsys/gfd.h>

      NNSGfdPlttKey NNS_GfdAllocPlttVram(u32 szByte, BOOL is4pltt, u32 opt);

## Arguments

`szByte` | Size of the palette-use memory you want to allocate (8 to 524280 bytes)
`is4pltt` | `TRUE` if 4-color palette-use memory is being allocated
`opt` | Options for Palette VRAM Memory Manager

## Return Values

The key data indicating the palette-use memory.

## Description

Allocates palette-use memory of the size specified by `szByte` from VRAM. The TWL-System library uses this function to allocate palette-use memory from Palette RAM.

The `NNS_GfdAllocPlttVram` function is defined as shown below. The only internal process this function conducts is calling the function set in the global function pointer `NNS_GfdDefaultFuncAllocPlttVram`.

    static inline NNSGfdPlttKey
    NNS_GfdAllocPlttVram(u32 szByte, BOOL is4pltt, u32 opt)
    {
        return (*NNS_GfdDefaultFuncAllocPlttVram)( szByte, is4pltt, opt );
    }

`NNS_GfdAllocPlttVram` works by registering the appropriate function for allocating palette-use memory in this function pointer. With this setup, the user can control the allocation of palette-use memory from the library. In the initial state, the function that is set in `NNS_GfdDefaultFuncAllocPlttVram` does nothing and returns an error. If an error occurs when palette-use memory is being allocated, the key `NNS_GFD_ALLOC_ERROR_PLTTKEY` is returned, indicating the error.

The `opt` parameter enables you to freely select how to use the function set in `NNS_GfdDefaultFuncAllocPlttVram` for allocating palette-use memory.

There is a restriction for the size that can be specified due to the specification of the bit expression inside the palette key. In addition, the amount of memory that you can allocate at one time depends on the implementation of the VRAM manager that is used to allocate memory.

## See Also

`NNS_GfdFreePlttVram`

## Revision History

2008/06/20 Changed NITRO-System to TWL-System.
2007/01/31 Added note specific to allocated sizes.
2005/01/31 Added note specific to size regions.
2004/07/16 Initial version.

CONFIDENTIAL