Keil™, An ARM® Company

C166 User's Guide

On-Line Manuals

C166 User's Guide

C166 Introduction
Compiling Programs
Language Extensions
Preprocessor
Advanced Programming
Error Messages
Library Reference
Library Files
Source Code
Standard Types
jmp_buf
ptrdiff_t
size_t
va_list
wchar_t
Macros
HARRAY
HVAR
MARRAY
MVAR
XARRAY
XVAR
Routines By Category
Buffer Manipulation Routines
Character Routines
Data Conversion Routines
Intrinsic Routines
Math Routines
Memory Allocation Routines
Stream I/O Routines
String Routines
Variable Length Argument Routines
Miscellaneous Routines
Include Files
SFR Definitions
absacc.h
assert.h
ctype.h
float.h
intrins.h
limits.h
math.h
membox.h
setjmp.h
stdarg.h
stddef.h
stdio.h
stdlib.h
string.h
Reference
_alloc_boxf
_alloc_boxh
_alloc_boxn
_atomic_
_bfld_
_calloc_boxf
_calloc_boxh
_calloc_boxn
_chkdouble_
_chkfloat_
_crol_
_cror_
_diswdt_
_einit_
_endatomic_
_free_boxf
_free_boxh
_free_boxn
_getkey
_idle_
_init_boxf
_init_boxh
_init_boxn
_irol_
_iror_
_lrol_
_lror_
_nop_
_pop_
_prior_
_priord_
_push_
_pwrdn_
_sof_
_srvwdt_
_testclear_
_testset_
_tolower
_toupper
_trap_
abs
acos
asin
assert
atan
atan2
atof
atoi
atol
calloc
calloc_b
ceil
cos
cosh
exp
fabs
floor
fmemccpy
fmemchr
fmemcmp
fmemcpy
fmemmove
fmemset
fmod
free
free_b
fstrcat
fstrchr
fstrcmp
fstrcpy
fstrcspn
fstrlen
fstrncat
fstrncmp
fstrncpy
fstrpbrk
fstrpos
fstrrchr
fstrrpbrk
fstrrpos
fstrspn
getchar
gets
hmemcmp
hmemcpy
hstrcmp
hstrcpy
init_mempool
init_mempool_b
isalnum
isalpha
iscntrl
isdigit
isgraph
islower
isprint
ispunct
isspace
isupper
isxdigit
labs
log
log10
longjmp
malloc
malloc_b
memccpy
memchr
memcmp
memcpy
memmove
memset
modf
offsetof
pow
printf
putchar
puts
rand
realloc
realloc_b
scanf
setjmp
sin
sinh
sprintf
sqrt
srand
sscanf
strcat
strchr
strcmp
strcpy
strcspn
strlen
strncat
strncmp
strncpy
strpbrk
strpos
strrchr
strrpbrk
strrpos
strspn
strstr
strtod
strtol
strtoul
tan
tanh
toascii
toint
tolower
toupper
ungetchar
va_arg
va_end
va_start
vprintf
vsprintf
xcalloc
xfree
xinit_mempool
xmalloc
xmemccpy
xmemchr
xmemcmp
xmemcpy
xmemmove
xmemset
xrealloc
xstrcmp
xstrcpy
xstrlen
xstrncpy
Appendix

Memory Allocation Routines

RoutineAttributesDescription
_alloc_boxfreentrantAllocates a fixed size far block from the specified memory pool.
_calloc_boxhreentrantAllocates a fixed size huge block from the specified memory pool.
_alloc_boxnreentrantAllocates a fixed size near block from the specified memory pool.
_calloc_boxfreentrantAllocates a fixed size far block from the specified memory pool.
_calloc_boxhreentrantReleases a fixed size block from the specified huge memory pool.
_calloc_boxnreentrantAllocates a fixed size near block from the specified memory pool.
_free_boxfreentrantFrees a fixed size block that was allocated using _alloc_boxf or _calloc_boxf.
_free_boxhreentrantFrees a fixed size block that was allocated using _alloc_boxh or _calloc_boxh.
_free_boxnreentrantFrees a fixed size block that was allocated using _alloc_boxn or _calloc_boxn.
_init_boxfreentrantInitializes the location and size of a far fixed block memory pool.
_init_boxhreentrantInitializes the location and size of a huge fixed block memory pool.
_init_boxnreentrantInitializes the location and size of a near fixed block memory pool.
calloc Allocates storage for an array from the memory pool.
calloc_b Allocates storage for an array from the xhuge memory pool.
free Frees a memory block that was allocated using calloc, malloc, or realloc.
free_b Frees a memory block that was allocated using calloc_b, malloc_b, or realloc_b.
init_mempool Initializes the memory location and size of the memory pool.
init_mempool_b Initializes the memory location and size of the xhuge memory pool.
malloc Allocates a block from the memory pool.
malloc_b Allocates a block from the xhuge memory pool.
realloc Reallocates a block from the memory pool.
realloc_b Reallocates a block from the xhuge memory pool.

The memory allocation functions provide you with a means to specify, allocate, and free blocks of memory from a memory pool. Standard memory allocation functions are implemented as functions and are prototyped in the stdlib.h include file. Fixed block size memory allocation routines are prototyped in membox.h.

Before using any of these functions to allocate memory, you must first specify the size and location of the memory pool using the init_mempool routine or the size, location, and block size using the _init_box? routines. All memory requests are satisfied from the specified memory block.

The calloc, malloc, _alloc_box?, and _calloc_box? routines allocate blocks of memory from the pool. The calloc routine allocates an array with a specified number of elements of a given size and initializes the array to 0. The malloc routine allocates a specified number of bytes. The _alloc_box? and _calloc_box? routines allocate a single fixed-size block from the memory pool.

The realloc routine changes the size of an allocated block. The free and _free_box? routines return a previously allocated memory block to the memory pool.