◐ Shell
clean mode source ↗

std::malloc - cppreference.com

De cppreference.com

<metanoindex/>

<tbody> </tbody>

Definido no cabeçalho

<cstdlib>

void* malloc( std::size_t size );

Aloca size bytes de armazenamento não inicializado.

Original:

Allocates size bytes of uninitialized storage.

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Se a alocação for bem sucedida, retorna um ponteiro para o byte mais baixo (primeiro) no bloco de memória alocada que é adequadamente alinhado para qualquer tipo de objeto.

Original:

If allocation succeeds, returns a pointer to the lowest (first) byte in the allocated memory block that is suitably aligned for any object type.

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Se size é zero, o comportamento é implementação definida (ponteiro nulo pode ser devolvida, ou algum ponteiro não nulo pode ser retornado que não pode ser utilizado para aceder a armazenamento)

Original:

If size is zero, the behavior is implementation defined (null pointer may be returned, or some non-null pointer may be returned that may not be used to access storage)

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Parâmetros

size -

número de bytes para alocar

Original:

number of bytes to allocate

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Valor de retorno

Ponteiro para o início da memória recém-alocado ou ponteiro nulo se o erro ocorreu. O ponteiro deve ser desalocado com free().

Original:

Pointer to the beginning of newly allocated memory or null pointer if error has occurred. The pointer must be deallocated with free().

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Notas

Esta função não chamar construtores ou inicializar a memória de qualquer forma. Assim, o método preferido de alocação de memória, é a expressão

new

.

Original:

This function does not call constructors or initialize memory in any way. Thus preferred method of memory allocation is

new

expression.

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Exemplo

Veja também

funções de alocação

Original:

allocation functions

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(função) [edit]

Obtém o armazenamento não inicializado

Original:

obtains uninitialized storage

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(modelo de função) [edit]

Documentação C para malloc