SOMCalloc: Difference between revisions
Appearance
Created page with "This function allocates sufficient memory for an array of objects of a specified size. ==Syntax== <PRE> size_t num; size_t size; somToken rc; rc = (*SomCalloc)(..." |
mNo edit summary |
||
(2 intermediate revisions by one other user not shown) | |||
Line 11: | Line 11: | ||
==Parameters== | ==Parameters== | ||
; num(size_t) : The number of objects for which space is to be allocated. | ;num(size_t) : The number of objects for which space is to be allocated. | ||
;size(size_t) : The size of the objects for which space to is to be allocated. | |||
; size(size_t) : The size of the objects for which space to is to be allocated. | |||
==Return Code== | ==Return Code== | ||
; rc(somToken) : A pointer to the first byte of the allocated space. | ;rc(somToken) : A pointer to the first byte of the allocated space. | ||
==Remarks== | ==Remarks== | ||
This function allocates an amount of memory equal to num*size (sufficient memory for an array of num objects of size size). This function has the same interface as the C calloc function. It performs the same basic function as calloc with some supplemental error checking. If an error occurs, the SOMError function is called. This routine is replaceable by changing the value of the global variable | This function allocates an amount of memory equal to num*size (sufficient memory for an array of num objects of size size). This function has the same interface as the C calloc function. It performs the same basic function as calloc with some supplemental error checking. If an error occurs, the [[SOMError]] function is called. This routine is replaceable by changing the value of the global variable | ||
SOMCalloc. | SOMCalloc. | ||
==Example Code== | ==Example Code== | ||
Line 26: | Line 25: | ||
==Related== | ==Related== | ||
;Data Structures | |||
* somToken (sombtype.h) | * somToken (sombtype.h) | ||
;Functions | |||
* [[SOMMalloc]] | * [[SOMMalloc]] | ||
* [[SOMRealloc]] | * [[SOMRealloc]] | ||
* [[somFree]] | * [[somFree]] | ||
[[Category:SOM Kernel]] | [[Category:SOM Kernel]] |
Latest revision as of 16:25, 12 October 2022
This function allocates sufficient memory for an array of objects of a specified size.
Syntax
size_t num; size_t size; somToken rc; rc = (*SomCalloc)(num, size);
Parameters
- num(size_t)
- The number of objects for which space is to be allocated.
- size(size_t)
- The size of the objects for which space to is to be allocated.
Return Code
- rc(somToken)
- A pointer to the first byte of the allocated space.
Remarks
This function allocates an amount of memory equal to num*size (sufficient memory for an array of num objects of size size). This function has the same interface as the C calloc function. It performs the same basic function as calloc with some supplemental error checking. If an error occurs, the SOMError function is called. This routine is replaceable by changing the value of the global variable SOMCalloc.
Example Code
See function somVprintf.
Related
- Data Structures
- somToken (sombtype.h)
- Functions