
malloc
7-38
Allocate Memory
malloc
Syntax
#include <stdlib.h>
void *
malloc
(size_t size);
Defined in
memory.c in rts.src
Description
The malloc function allocates space for an object of size bytes and returns a
pointer to the space. If malloc cannot allocate the packet (that is, if it runs out
of memory), it returns a null pointer (0). This function does not modify the
memory it allocates.
The memory that malloc uses is in a special memory pool or heap. The
constant __SYSTEM_SIZE defines the size of the heap as 1K words. You can
change this amount at link time by invoking the linker with the -heap option and
specifying the desired size of the heap directly after the option. For more
information, see section 6.1.4,
Dynamic Memory Allocation
Example
This example allocates free space for a structure.
struct xyz *p;
p =
malloc
(sizeof (struct xyz));
Find First Occurrence of Byte
memchr
Syntax
#include <string.h>
void *
memchr
(const void *es, int c, size_t n);
Defined in
memchr.c in rts.src
Description
The memchr function finds the first occurrence of c in the first n characters of
the object that es points to. If the character is found, memchr returns a pointer
to the located character; otherwise, it returns a null pointer (0).
The memchr function is similar to strchr, except that the object that memchr
searches can contain values of 0 and c can be 0. The memchr function is
expanded inline when the
−
x option is used.
Содержание TMS320C2x
Страница 8: ...viii...
Страница 69: ...2 47 C Compiler Description...
Страница 159: ...6 36...
Страница 226: ...8 6...
Страница 250: ...Index Index 14 Z z shell option 2 2 2 4 2 14 overriding with c option 4 5 overriding with n option 2 13...