Wpis z mikrobloga

Może mi ktoś wytłumaczyć co robię nie tak?

int *xd = (int *)calloc(-1,sizeof(int));
efekt:

src/utils.cu:207:24: warning: argument 1 value ‘18446744073709551615’ exceeds maximum object size 9223372036854775807 [-Walloc-size-larger-than=]
207 | int *xd = (int *)calloc(-1,sizeof(int));

#programowanie #c #cplusplus
  • 10
@jaroslawII: void *calloc(size_t nmemb, size_t size);
The calloc() function allocates memory for an array of nmemb elements of size bytes each and returns a pointer to the allocated memory. The memory is set to zero. If nmemb or size is 0, then calloc() returns either NULL, or a unique pointer value that can later be successfully passed to free().
@dupasmoka: to podałem tylko jako przykład a chodziło mi o alokacje i wypełnienie sporej tablicy

newMat->colind = (int *)malloc(sizeof(int) * (inputMatrix->M * maxNonZerosPerRow));
a sam kod jest pod CUDE więc zostanę przy funkcjach na kodzie których się wzoruje