名前空間
変種
操作

calloc

提供: cppreference.com
< c‎ | memory

Defined in header <stdlib.h>
void* calloc( size_t num, size_t size );
割り当てサイズnumsizeオブジェクトの配列のためのメモリおよびゼロ初期化し、それを.
Original:
Allocates memory for an array of num objects of size size and zero-initializes it.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
割り当てが成功した場合、適当に任意のオブジェクト型に整列された割り当てられたメモリブロックの最下位(最初の)バイトへのポインタを返す.
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.
sizeがゼロの場合、動作は実装定義(nullポインタが返されることがあります、または一部の非NULLポインタがストレージにアクセスするために使用されない場合があり、その戻される場合があります)
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.

目次

[編集] パラメータ

num -
オブジェクトの数
Original:
number of objects
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
size -
各オブジェクトのサイズ
Original:
size of each object
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集] 値を返します

エラーが発生した場合、新たに割り当てられたメモリやNULLの先頭を指すポインタ。ポインタはfree()を使って解放する必要があります.
Original:
Pointer to the beginning of newly allocated memory or NULL 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.

[編集] ノート

アラインメントの要件のために、割り当てられたバイト数がnum*sizeとは必ずしも一致しないです.
Original:
Due to the alignment requirements, the number of allocated bytes is not necessarily equal to num*size.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集] も参照してください