Embedded Artistry Framework
Embedded Systems C++ Framework
Classes | Macros | Functions
stdlib.h File Reference
#include <stddef.h>
#include <stdint.h>
#include <wctype.h>
Include dependency graph for stdlib.h:
This graph shows which files directly or indirectly include this file:

Classes

struct  div_t
 Division type for integers. More...
 
struct  ldiv_t
 Division type for long integers. More...
 
struct  lldiv_t
 Division type for long long integers. More...
 
struct  imaxdiv_t
 Division type for maximal integer storage. More...
 

Macros

#define EXIT_FAILURE   1
 
#define EXIT_SUCCESS   0
 
#define RAND_MAX   (0x7fffffff)
 
#define MB_CUR_MAX   sizeof(wchar_t)
 Length of the current locale's multi-byte character. More...
 

Functions

void abort (void) __attribute__((noreturn))
 
int atexit (void(*)(void))
 
void exit (int) __attribute__((noreturn))
 
void _Exit (int) __attribute__((noreturn))
 TODO: CLEANUP DOC Terminates the process normally by returning control to the host environment, but without performing any of the regular cleanup tasks for terminating processes (as function exit does). More...
 
int at_quick_exit (void(*)(void))
 
void quick_exit (int) __attribute__((noreturn))
 
int cxa_atexit (void(*)(void *), void *, void *)
 
char * getenv (const char *)
 
int system (const char *)
 
int mblen (const char *, size_t)
 
int mbtowc (wchar_t *__restrict, const char *__restrict, size_t)
 
int wctomb (char *, wchar_t)
 
size_t mbstowcs (wchar_t *__restrict, const char *__restrict, size_t)
 
size_t wcstombs (char *__restrict, const wchar_t *__restrict, size_t)
 
int atoi (const char *str)
 Interprets an integer value in a byte string pointed to by str. More...
 
long atol (const char *str)
 Interprets a Long value in a byte string pointed to by str. More...
 
long long atoll (const char *str)
 Interprets a Long Long value in a byte string pointed to by str. More...
 
double atof (const char *str)
 Interprets a floating-point value in a byte string pointed to by str. More...
 
float strtof (const char *__restrict str, char **__restrict str_end)
 Interprets a floating-point value in a byte string pointed to by str. More...
 
double strtod (const char *__restrict str, char **__restrict str_end)
 Interprets a floating-point value in a byte string pointed to by str. More...
 
long strtol (const char *__restrict str, char **__restrict str_end, int base)
 Interprets an long value in a byte string pointed to by str. More...
 
unsigned long strtoul (const char *__restrict str, char **__restrict str_end, int base)
 Interprets an unsigned long value in a byte string pointed to by str. More...
 
long long strtoll (const char *__restrict str, char **__restrict str_end, int base)
 Interprets an long long value in a byte string pointed to by str. More...
 
unsigned long long strtoull (const char *__restrict str, char **__restrict str_end, int base)
 Interprets an unsigned long long value in a byte string pointed to by str. More...
 
long double strtold (const char *__restrict, char **__restrict)
 
int abs (int n)
 Computes the absolute value of an integer number. More...
 
long labs (long n)
 Computes the absolute value of an long number. More...
 
long long llabs (long long n)
 Computes the absolute value of an long long number. More...
 
intmax_t imaxabs (intmax_t j)
 Computes the absolute value of an intmax_t number. More...
 
div_t div (int x, int y)
 Computes both the quotient and the remainder of the division of the numerator x by the denominator y. More...
 
ldiv_t ldiv (long x, long y)
 Computes both the quotient and the remainder of the division of the numerator x by the denominator y. More...
 
lldiv_t lldiv (long long x, long long y)
 Computes both the quotient and the remainder of the division of the numerator x by the denominator y. More...
 
imaxdiv_t imaxdiv (intmax_t numer, intmax_t denom)
 Computes both the quotient and the remainder of the division of the numerator x by the denominator y. More...
 
int rand_r (unsigned int *ctx)
 
int rand (void)
 Returns a pseudo-random integer value between ​0​ and. More...
 
void srand (unsigned seed)
 Seeds the pseudo-random number generator used by. More...
 
int heapsort (void *vbase, size_t nmemb, size_t size, int(*compar)(const void *, const void *))
 Sorts the given array pointed to by vbase in ascending order. More...
 
int heapsort_r (void *vbase, size_t nmemb, size_t size, void *thunk, int(*compar)(void *, const void *, const void *))
 Sorts the given array pointed to by vbase in ascending order. More...
 
void * bsearch (const void *key, const void *ptr, size_t count, size_t size, int(*comp)(const void *, const void *))
 Finds an element equal to element pointed to by key in an array pointed to by ptr. More...
 
void qsort_r (void *a, size_t n, size_t es, void *thunk, int(*cmp)(void *, const void *, const void *))
 Sorts the given array pointed to by ptr in ascending order. More...
 
void qsort (void *a, size_t n, size_t es, int(*compar)(const void *, const void *))
 Sorts the given array pointed to by ptr in ascending order. More...
 
void * malloc (size_t size)
 Allocates size bytes of uninitialized storage. More...
 
void free (void *ptr)
 Deallocates allocated memory space. More...
 
void * calloc (size_t num, size_t size)
 Allocates memory for an array of given number objects of size and initializes all bytes in the allocated storage to zero. More...
 
void * realloc (void *ptr, size_t size)
 Reallocates the given area of memory. More...
 
void * reallocf (void *ptr, size_t size)
 Reallocates the given area of memory. More...
 

Class Documentation

◆ div_t

struct div_t

Division type for integers.

Class Members
int quot The quotient.
int rem The remainder.

◆ ldiv_t

struct ldiv_t

Division type for long integers.

Class Members
long quot The quotient.
long rem The remainder.

◆ lldiv_t

struct lldiv_t

Division type for long long integers.

Class Members
long long quot The quotient.
long long rem The remainder.

◆ imaxdiv_t

struct imaxdiv_t

Division type for maximal integer storage.

Class Members
intmax_t quot The quotient.
intmax_t rem The remainder.

Macro Definition Documentation

◆ EXIT_FAILURE

#define EXIT_FAILURE   1

Expands to 1. Indicates program execution execution status.

◆ EXIT_SUCCESS

#define EXIT_SUCCESS   0

Expands to 0. indicates program execution execution status.

◆ MB_CUR_MAX

#define MB_CUR_MAX   sizeof(wchar_t)

Length of the current locale's multi-byte character.

We are faking this for now, since we don't provide locale support.

◆ RAND_MAX

#define RAND_MAX   (0x7fffffff)

Expands to an integer constant expression equal to the maximum value returned by the function

See also
rand() It's guaranteed that this value is at least 32767

Function Documentation

◆ _Exit()

void _Exit ( int  )

TODO: CLEANUP DOC Terminates the process normally by returning control to the host environment, but without performing any of the regular cleanup tasks for terminating processes (as function exit does).

No object destructors, nor functions registered by atexit or at_quick_exit are called

Referenced by __attribute__().

◆ abort()

void abort ( void  )

Referenced by __attribute__().

◆ abs()

int abs ( int  n)

Computes the absolute value of an integer number.

Computes the absolute value of an integer number. The behavior is undefined if the result cannot be represented by the return type.

Parameters
ninteger value
Returns
The absolute value of n (i.e. |n|), if it is representable.

Referenced by abs_test(), check_int(), and embdrv::ssd1306::line().

Here is the caller graph for this function:

◆ at_quick_exit()

int at_quick_exit ( void(*)(void)  )

◆ atexit()

int atexit ( void(*)(void)  )

◆ atof()

double atof ( const char *  str)

Interprets a floating-point value in a byte string pointed to by str.

Interprets a floating-point value in a byte string pointed to by str. Function discards any whitespace characters (as determined by

See also
isspace() until first non-whitespace character is found. Then it takes as many characters as possible to form a valid floating-point representation and converts them to a floating-point value. The valid floating-point value can be one of the following: 1) decimal floating-point expression. It consists of the following parts: a) (optional) plus or minus sign b) nonempty sequence of decimal digits optionally containing decimal-point character c) (optional) e or E followed with optional minus or plus sign and nonempty sequence of decimal digits (defines exponent)
Parameters
strpointer to the null-terminated byte string to be interpreted
Returns
double value corresponding to the contents of str on success. If the converted value falls out of range of corresponding return type, the return value is undefined. If no conversion can be performed, ​0​.0 is returned.

References NULL, and strtod().

Referenced by atof_test().

Here is the caller graph for this function:

◆ atoi()

int atoi ( const char *  str)

Interprets an integer value in a byte string pointed to by str.

Interprets an integer value in a byte string pointed to by str. Discards any whitespace characters until the first non-whitespace character is found, then takes as many characters as possible to form a valid integer number representation and converts them to an integer value. The valid integer value consists of the following parts: a) (optional) plus or minus sign b) numeric digits

Parameters
strpointer to the null-terminated byte string to be interpreted
Returns
Integer value corresponding to the contents of str on success. If the converted value falls out of range of corresponding return type, the return value is undefined. If no conversion can be performed, ​0​ is returned.

References isdigit().

Referenced by atoi_test(), and main().

Here is the caller graph for this function:

◆ atol()

long atol ( const char *  str)

Interprets a Long value in a byte string pointed to by str.

Interprets a Long value in a byte string pointed to by str. Discards any whitespace characters until the first non-whitespace character is found, then takes as many characters as possible to form a valid long number representation and converts them to an long value. The valid Long value consists of the following parts: a) (optional) plus or minus sign b) numeric digits

Parameters
strpointer to the null-terminated byte string to be interpreted
Returns
long value corresponding to the contents of str on success. If the converted value falls out of range of corresponding return type, the return value is undefined. If no conversion can be performed, ​0​ is returned.

References isdigit(), and isspace().

Referenced by atol_test().

Here is the caller graph for this function:

◆ atoll()

long long atoll ( const char *  str)

Interprets a Long Long value in a byte string pointed to by str.

Interprets a Long Long value in a byte string pointed to by str. Discards any whitespace characters until the first non-whitespace character is found, then takes as many characters as possible to form a valid long number representation and converts them to an long long value. The valid Long long value consists of the following parts: a) (optional) plus or minus sign b) numeric digits

Parameters
strpointer to the null-terminated byte string to be interpreted
Returns
long value corresponding to the contents of str on success. If the converted value falls out of range of corresponding return type, the return value is undefined. If no conversion can be performed, ​0​ is returned.

References isdigit(), and isspace().

Referenced by atoll_test().

Here is the caller graph for this function:

◆ bsearch()

void* bsearch ( const void *  key,
const void *  ptr,
size_t  count,
size_t  size,
int(*)(const void *, const void *)  comp 
)

Finds an element equal to element pointed to by key in an array pointed to by ptr.

Parameters
keypointer to the element to search for
ptrpointer to the array to examine
countnumber of element in the array
sizesize of each element in the array in bytes
compcomparison function which returns ​a negative integer value if the first argument is less than the second,a positive integer value if the first argument is greater than the second and zero if the arguments are equal. key is passed as the first argument, an element from the array as the second. The signature of the comparison function should be equivalent to the following: int cmp(const void *a, const void *b); The function must not modify the objects passed to it and must return consistent results when called for the same objects, regardless of their positions in the array.
Returns
Pointer to an element in the array that compares equal to *key, or null pointer if such element has not been found.

◆ calloc()

void* calloc ( size_t  num,
size_t  size 
)

Allocates memory for an array of given number objects of size and initializes all bytes in the allocated storage to zero.

Allocates memory for an array of num objects of size size and initializes all bytes in the allocated storage to zero.

Parameters
numnumber of objects
sizesize of the array
Returns
(None)

References malloc(), memset(), MUL_NO_OVERFLOW, NULL, and SIZE_MAX.

Referenced by calloc_test(), and t_choose().

Here is the caller graph for this function:

◆ cxa_atexit()

int cxa_atexit ( void(*)(void *)  ,
void *  ,
void *   
)

◆ div()

div_t div ( int  x,
int  y 
)

Computes both the quotient and the remainder of the division of the numerator x by the denominator y.

Computes both the quotient and the remainder of the division of the numerator x by the denominator y.

Parameters
xinteger values
yinteger values
Returns
If both the remainder and the quotient can be represented as objects of the corresponding type (int, long, long long, imaxdiv_t, respectively), returns both as an object of type
See also
div_t,
ldiv_t,
lldiv_t,
imaxdiv_t.

If either the remainder or the quotient cannot be represented, the behavior is undefined.

References r.

Referenced by div_test(), and lldiv_test().

Here is the caller graph for this function:

◆ exit()

void exit ( int  )

Referenced by main().

◆ free()

void free ( void *  ptr)

Deallocates allocated memory space.

Deallocates the space previously allocated by

See also
malloc,
calloc,
realloc. If ptr is a null pointer, the function does nothing.

The behavior is undefined if the value of ptr does not equal a value returned earlier by

See also
malloc,
calloc,
realloc.

The behavior is undefined if the memory area referred to by ptr has already been deallocated, that is, free() or realloc has already been called with ptr as the argument and no calls to malloc, calloc or realloc resulted in a pointer equal to ptr afterwards.

The behavior is undefined if after free returns, an access is made through the pointer ptr (unless another allocation function happened to result in a pointer value equal to ptr)

Parameters
ptrpointer to the memory to deallocate

free should NEVER be called before malloc is init'd

free should NEVER be called before malloc is init'd

References assert, container_of, defrag_free_list(), embvm::VirtualHeap< THeapImpl >::free(), initialized_, list_add_tail(), list_for_each_entry, list_insert(), alloc_node_t::node, ll_head::prev, r, tx_byte_release(), and TX_SUCCESS.

Referenced by _readMemory(), aligned_free(), calloc_test(), char_test(), embvm::VirtualHeap< THeapImpl >::free(), heapsort(), heapsort_r(), malloc_test(), realloc(), reallocf(), strdup_test(), strndup_test(), and t_choose().

Here is the caller graph for this function:

◆ getenv()

char* getenv ( const char *  )

◆ heapsort()

int heapsort ( void *  vbase,
size_t  nmemb,
size_t  size,
int(*)(const void *, const void *)  compar 
)

Sorts the given array pointed to by vbase in ascending order.

The heapsort() function is a modified selection sort. It sorts an array of nmemb objects, the initial member of which is pointed to by vbase. The size of each object is specified by size.

The contents of the array base are sorted in ascending order according to a comparison function pointed to by compar, which requires two arguments pointing to the objects being compared.

Parameters
vbasea pointer to the array to sort
nmembthe number of objects to sort
sizethe size of each object in the array
comparcomparison function which returns ​a negative integer value if the first argument is less than the second,a positive integer value if the first argument is greater than the second and zero if the arguments are equal. key is passed as the first argument, an element from the array as the second. The signature of the comparison function should be equivalent to the following: int cmp(const void *a, const void *b);
Returns
the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indicate the error.

Referenced by _qsort().

◆ heapsort_r()

int heapsort_r ( void *  vbase,
size_t  nmemb,
size_t  size,
void *  thunk,
int(*)(void *, const void *, const void *)  compar 
)

Sorts the given array pointed to by vbase in ascending order.

It sorts an array of nmemb objects, the initial member of which is pointed to by vbase. The size of each object is specified by size. The heapsort_r() function behaves identically to

See also
heapsort(), except that it takes an additional argument, thunk, which is passed unchanged as the first argument to function pointed to compar. This allows the comparison function to access additional data without using global variables, and thus heapsort_r() is suitable for use in functions which must be reentrant. And is therefore reentrant and safe to use in threads.

The contents of the array base are sorted in ascending order according to a comparison function pointed to by compar, which requires two arguments pointing to the objects being compared.

Parameters
vbasea pointer to the array to sort
nmembthe number of objects to sort
sizethe size of each object in the array
thunkadditional data(variable) for compar
comparcomparison function which returns ​a negative integer value if the first argument is less than the second,a positive integer value if the first argument is greater than the second and zero if the arguments are equal. key is passed as the first argument, an element from the array as the second. The signature of the comparison function should be equivalent to the following: int cmp(const void *a, const void *b);
Returns
the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indicate the error.

Referenced by _qsort().

◆ imaxabs()

intmax_t imaxabs ( intmax_t  j)

Computes the absolute value of an intmax_t number.

Computes the absolute value of an intmax_t number. The behavior is undefined if the result cannot be represented by the return type.

Parameters
jvalue
Returns
The absolute value of n (i.e. |n|), if it is representable.

Referenced by imaxabs_test(), labs_test(), and llabs_test().

Here is the caller graph for this function:

◆ imaxdiv()

imaxdiv_t imaxdiv ( intmax_t  numer,
intmax_t  denom 
)

Computes both the quotient and the remainder of the division of the numerator x by the denominator y.

Computes both the quotient and the remainder of the division of the numerator x by the denominator y. Computes quotient and remainder simultaneously. The quotient is the algebraic quotient with any fractional part discarded (truncated towards zero). The remainder is such that quot * y + rem == x.

Computes the quotient (the result of the expression x/y) and remainder (the result of the expression xy) simultaneously.

Parameters
numerintmax_t values (numerator)
denomintmax_t values (denominator)
Returns
If both the remainder and the quotient can be represented as objects of the corresponding type (int, long, long long, imaxdiv_t, respectively), returns both as an object of type
See also
div_t,
ldiv_t,
lldiv_t,
imaxdiv_t.

If either the remainder or the quotient cannot be represented, the behavior is undefined.

References imaxdiv_t::quot, and imaxdiv_t::rem.

◆ labs()

long labs ( long  n)

Computes the absolute value of an long number.

Computes the absolute value of an long number. The behavior is undefined if the result cannot be represented by the return type.

Parameters
nlong value
Returns
The absolute value of n (i.e. |n|), if it is representable.

Referenced by check_long().

Here is the caller graph for this function:

◆ ldiv()

ldiv_t ldiv ( long  x,
long  y 
)

Computes both the quotient and the remainder of the division of the numerator x by the denominator y.

Computes both the quotient and the remainder of the division of the numerator x by the denominator y. Computes quotient and remainder simultaneously. The quotient is the algebraic quotient with any fractional part discarded (truncated towards zero). The remainder is such that quot * y + rem == x.

Computes the quotient (the result of the expression x/y) and remainder (the result of the expression xy) simultaneously.

Parameters
xinteger values
yinteger values
Returns
If both the remainder and the quotient can be represented as objects of the corresponding type (int, long, long long, imaxdiv_t, respectively), returns both as an object of type
See also
div_t,
ldiv_t,
lldiv_t,
imaxdiv_t.

If either the remainder or the quotient cannot be represented, the behavior is undefined.

References r.

◆ llabs()

long long llabs ( long long  n)

Computes the absolute value of an long long number.

Computes the absolute value of an long long number. The behavior is undefined if the result cannot be represented by the return type.

Parameters
nlong long value
Returns
The absolute value of n (i.e. |n|), if it is representable.

Referenced by check_longlong().

Here is the caller graph for this function:

◆ lldiv()

lldiv_t lldiv ( long long  x,
long long  y 
)

Computes both the quotient and the remainder of the division of the numerator x by the denominator y.

Computes both the quotient and the remainder of the division of the numerator x by the denominator y. Computes quotient and remainder simultaneously. The quotient is the algebraic quotient with any fractional part discarded (truncated towards zero). The remainder is such that quot * y + rem == x.

Computes the quotient (the result of the expression x/y) and remainder (the result of the expression xy) simultaneously.

Parameters
xinteger values
yinteger values
Returns
If both the remainder and the quotient can be represented as objects of the corresponding type (int, long, long long, imaxdiv_t, respectively), returns both as an object of type
See also
div_t,
ldiv_t,
lldiv_t,
imaxdiv_t.

If either the remainder or the quotient cannot be represented, the behavior is undefined.

References lldiv_t::quot, and lldiv_t::rem.

◆ malloc()

void* malloc ( size_t  size)

Allocates size bytes of uninitialized storage.

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, but has to be passed to

See also
free). malloc is thread-safe: it behaves as though only accessing the memory locations visible through its argument, and not any static storage.
Parameters
sizenumber of bytes to allocate
Returns
On success, returns the pointer to the beginning of newly allocated memory. The returned pointer must be deallocated with
See also
free() or
realloc(). On failure, returns a null pointer.

In the ThreadX implementaiton, we make sure the ThreadX pool has been created before we try to allocate memory, or there will be an error. We sleep our threads until memory has been added.

References align_up, embvm::VirtualHeap< THeapImpl >::alloc(), ALLOC_HEADER_SZ, assert, alloc_node_t::block, initialized_, list_del(), list_for_each_entry, list_insert(), malloc_pool_, MIN_ALLOC_SZ, ll_head::next, alloc_node_t::node, NULL, r, alloc_node_t::size, tx_byte_allocate(), TX_SUCCESS, tx_thread_sleep(), and TX_WAIT_FOREVER.

Referenced by _readMemory(), aligned_malloc(), calloc(), char_test(), heapsort(), heapsort_r(), malloc_test(), realloc(), strdup(), strndup(), t_choose(), and vasprintf().

Here is the caller graph for this function:

◆ mblen()

int mblen ( const char *  ,
size_t   
)

◆ mbstowcs()

size_t mbstowcs ( wchar_t __restrict,
const char *  __restrict,
size_t   
)

◆ mbtowc()

int mbtowc ( wchar_t __restrict,
const char *  __restrict,
size_t   
)

◆ qsort()

void qsort ( void *  a,
size_t  n,
size_t  es,
int(*)(const void *, const void *)  compar 
)

Sorts the given array pointed to by ptr in ascending order.

Sorts the given array pointed to by ptr in ascending order. The array contains count elements of size bytes. Function pointed to by comp is used for object comparison.

Parameters
apointer to the element to sort
nnumber of element in the array
essize of each element in the array in bytes
comparcomparison function which returns ​a negative integer value if the first argument is less than the second,a positive integer value if the first argument is greater than the second and zero if the arguments are equal. key is passed as the first argument, an element from the array as the second. The signature of the comparison function should be equivalent to the following: int cmp(const void *a, const void *b); The function must not modify the objects passed to it and must return consistent

Referenced by __attribute__(), and os::freertos::Heap::init().

◆ qsort_r()

void qsort_r ( void *  a,
size_t  n,
size_t  es,
void *  thunk,
int(*)(void *, const void *, const void *)  cmp 
)

Sorts the given array pointed to by ptr in ascending order.

The qsort_r() function behaves identically to

See also
qsort(), except that it takes an additional argument, thunk, which is passed unchanged as the first argument to function pointed to compar. This allows the comparison function to access additional data without using global variables, and thus qsort_r() is suitable for use in functions which must be reentrant. And is therefore reentrant and safe to use in threads.
Parameters
apointer to the element to sort
nnumber of element in the array
essize of each element in the array in bytes
thunkadditional data(variable) for cmp
cmpcomparison function which returns ​a negative integer value if the first argument is less than the second,a positive integer value if the first argument is greater than the second and zero if the arguments are equal. key is passed as the first argument, an element from the array as the second. The signature of the comparison function should be equivalent to the following: int cmp(const void *a, const void *b); The function must not modify the objects passed to it and must return consistent

Referenced by char_test(), qsort_r_int_test(), qsort_r_string_test(), and uint64_test().

◆ quick_exit()

void quick_exit ( int  )

◆ rand()

int rand ( void  )

Returns a pseudo-random integer value between ​0​ and.

See also
RAND_MAX (0 and
RAND_MAX included).

Returns a pseudo-random integer value between ​0​ and

See also
RAND_MAX (0 and
RAND_MAX included).
srand() seeds the pseudo-random number generator used by rand. If rand is used before any calls to
srand, rand behaves as if it was seeded with
srand. Each time rand is seeded with srand, it must produce the same sequence of values.

rand is not guaranteed to be thread-safe.

Returns
Pseudo-random integer value between ​0​ and RAND_MAX, inclusive.

References do_rand(), and next.

Referenced by main().

Here is the caller graph for this function:

◆ rand_r()

int rand_r ( unsigned int *  ctx)

References do_rand(), and r.

◆ realloc()

void* realloc ( void *  ptr,
size_t  size 
)

Reallocates the given area of memory.

Reallocates the given area of memory. It must be previously allocated by

See also
malloc,
calloc or
realloc and not yet freed with a call to
free or
realloc. Otherwise, the results are undefined.

The reallocation is done by either: 1) expanding or contracting the existing area pointed to by ptr, if possible. The contents of the area remain unchanged up to the lesser of the new and old sizes. If the area is expanded, the contents of the new part of the array are undefined. 2) allocating a new memory block of size size bytes, copying memory area with size equal the lesser of the new and the old sizes, and freeing the old block.

If there is not enough memory, the old memory block is not freed and null pointer is returned. If ptr is NULL, the behavior is the same as calling malloc(size).

Parameters
ptrpointer to the memory area to be reallocated
sizenew size of the array
Returns
pointer to new memory allocation. If size is zero (e.g. realloc(ptr,0)) then returns NULL

References free(), malloc(), memcpy(), and NULL.

Referenced by reallocf().

Here is the caller graph for this function:

◆ reallocf()

void* reallocf ( void *  ptr,
size_t  size 
)

Reallocates the given area of memory.

Reallocates the given area of memory. It must be previously allocated by

See also
malloc,
calloc or
realloc and not yet freed with a call to
free or
realloc. Otherwise, the results are undefined.

reallocf is a FreeBSD extension to realloc that frees the input pointer if an error occurrs

This library does not handle the BSD case where realloc(ptr,0) frees the ptr

Parameters
ptrpointer to the memory area to be reallocated
sizenew size of the array
Returns
pointer to new memory allocation. If size is zero (e.g. realloc(ptr,0)) then returns NULL

References free(), NULL, p, and realloc().

◆ srand()

void srand ( unsigned  seed)

Seeds the pseudo-random number generator used by.

See also
rand with the value seed.

Seeds the pseudo-random number generator used by

See also
rand with the value seed. If rand() is used before any calls to srand,
rand behaves as if it was seeded with srand. Each time rand is seeded with the same seed, it must produce the same sequence of values.

srand() is not guaranteed to be thread-safe.

Parameters
seedthe seed value

◆ strtod()

double strtod ( const char *__restrict  str,
char **__restrict  str_end 
)

Interprets a floating-point value in a byte string pointed to by str.

Interprets a floating-point value in a byte string pointed to by str. Function discards any whitespace characters (as determined by

See also
isspace()) until first non-whitespace character is found. Then it takes as many characters as possible to form a valid floating-point representation and converts them to a floating-point value. The valid floating-point value can be one of the following: a) decimal floating-point expression. It consists of the following parts: 1) (optional) plus or minus sign 2) nonempty sequence of decimal digits optionally containing decimal-point character (as determined by the current C locale) (defines significand) 3) (optional) e or E followed with optional minus or plus sign and nonempty sequence of decimal digits (defines exponent) b) binary floating-point expression. It consists of the following parts: 1) (optional) plus or minus sign 2) 0x or 0X c) infinity expression. It consists of the following parts: 1) (optional) plus or minus sign 2) INF or INFINITY ignoring case d) not-a-number expression. It consists of the following parts: 1) (optional) plus or minus sign 2) NAN or NAN(char_sequence) ignoring case of the NAN part. char_sequence can only contain digits, Latin letters, and underscores. The result is a quiet NaN floating-point value.

The functions sets the pointer pointed to by str_end to point to the character past the last character interpreted. If str_end is NULL, it is ignored.

Parameters
stra pointer to the null-terminated byte string to be interpreted
str_endpointer to a pointer to character
Returns
Floating-point value corresponding to the contents of str on success. If the converted value falls out of range of corresponding return type, range error occurs and HUGE_VAL, HUGE_VALF or HUGE_VALL is returned. If no conversion can be performed, ​0​ is returned.

Referenced by atof(), and strtold().

◆ strtof()

float strtof ( const char *__restrict  str,
char **__restrict  str_end 
)

Interprets a floating-point value in a byte string pointed to by str.

Interprets a floating-point value in a byte string pointed to by str. Function discards any whitespace characters (as determined by

See also
isspace()) until first non-whitespace character is found. Then it takes as many characters as possible to form a valid floating-point representation and converts them to a floating-point value. The valid floating-point value can be one of the following: a) decimal floating-point expression. It consists of the following parts: 1) (optional) plus or minus sign 2) nonempty sequence of decimal digits optionally containing decimal-point character (as determined by the current C locale) (defines significand) 3) (optional) e or E followed with optional minus or plus sign and nonempty sequence of decimal digits (defines exponent) b) binary floating-point expression. It consists of the following parts: 1) (optional) plus or minus sign 2) 0x or 0X c) infinity expression. It consists of the following parts: 1) (optional) plus or minus sign 2) INF or INFINITY ignoring case d) not-a-number expression. It consists of the following parts: 1) (optional) plus or minus sign 2) NAN or NAN(char_sequence) ignoring case of the NAN part. char_sequence can only contain digits, Latin letters, and underscores. The result is a quiet NaN floating-point value.

The functions sets the pointer pointed to by str_end to point to the character past the last character interpreted. If str_end is NULL, it is ignored.

Parameters
stra pointer to the null-terminated byte string to be interpreted
str_endpointer to a pointer to character
Returns
Floating-point value corresponding to the contents of str on success. If the converted value falls out of range of corresponding return type, range error occurs and HUGE_VAL, HUGE_VALF or HUGE_VALL is returned. If no conversion can be performed, ​0​ is returned.

◆ strtol()

long strtol ( const char *__restrict  str,
char **__restrict  str_end,
int  base 
)

Interprets an long value in a byte string pointed to by str.

Interprets an long value in a byte string pointed to by str. Discards any whitespace characters (as identified by calling

See also
isspace()) until the first non-whitespace character is found, then takes as many characters as possible to form a valid base-n (where n=base) long number representation and converts them to an long value. The valid long value consists of the following parts:
 1) (optional) plus or minus sign
 2) (optional) prefix (0) indicating octal base (applies only when the base is 8 or ​0​)
 3) (optional) prefix (0x or 0X) indicating hexadecimal base (applies only when the base is
16 or ​0​) 4) a sequence of digits

The set of valid values for base is {0,2,3,...,36}. The set of valid digits for base-2 integers is {0,1}, for base-3 integers is {0,1,2}, and so on. For bases larger than 10, valid digits include alphabetic characters, starting from Aa for base-11 integer, to Zz for base-36 integer. The case of the characters is ignored.

If the value of base is ​0​, the numeric base is auto-detected: if the prefix is 0, the base is octal, if the prefix is 0x or 0X, the base is hexadecimal, otherwise the base is decimal.

If the minus sign was part of the input sequence, the numeric value calculated from the sequence of digits is negated as if by unary minus in the result type.

The functions sets the pointer pointed to by str_end to point to the character past the last character interpreted. If str_end is NULL, it is ignored.

If the str is empty or does not have the expected form, no conversion is performed, and (if str_end is not NULL) the value of str is stored in the object pointed to by str_end.

Parameters
strpointer to the null-terminated byte string to be interpreted
str_endpointer to a pointer to character.
basebase of the interpreted integer value
Returns
returns the result of the conversion, unless the value would underflow or overflow. If the converted value falls out of range of corresponding return type, a range error occurs (setting errno to ERANGE) and LONG_MAX, LONG_MIN, LLONG_MAX or LLONG_MIN is returned. If no conversion can be performed, ​0​ is returned.

Referenced by main().

◆ strtold()

long double strtold ( const char *  __restrict,
char **  __restrict 
)

◆ strtoll()

long long strtoll ( const char *__restrict  str,
char **__restrict  str_end,
int  base 
)

Interprets an long long value in a byte string pointed to by str.

Interprets an long value in a byte string pointed to by str. Discards any whitespace characters (as identified by calling

See also
isspace()) until the first non-whitespace character is found, then takes as many characters as possible to form a valid base-n (where n=base) long number representation and converts them to an long long value. The valid long value consists of the following parts:
 1) (optional) plus or minus sign
 2) (optional) prefix (0) indicating octal base (applies only when the base is 8 or ​0​)
 3) (optional) prefix (0x or 0X) indicating hexadecimal base (applies only when the base is
16 or ​0​) 4) a sequence of digits

The set of valid values for base is {0,2,3,...,36}. The set of valid digits for base-2 integers is {0,1}, for base-3 integers is {0,1,2}, and so on. For bases larger than 10, valid digits include alphabetic characters, starting from Aa for base-11 integer, to Zz for base-36 integer. The case of the characters is ignored.

If the value of base is ​0​, the numeric base is auto-detected: if the prefix is 0, the base is octal, if the prefix is 0x or 0X, the base is hexadecimal, otherwise the base is decimal.

If the minus sign was part of the input sequence, the numeric value calculated from the sequence of digits is negated as if by unary minus in the result type.

The functions sets the pointer pointed to by str_end to point to the character past the last character interpreted. If str_end is NULL, it is ignored.

If the str is empty or does not have the expected form, no conversion is performed, and (if str_end is not NULL) the value of str is stored in the object pointed to by str_end.

Parameters
strpointer to the null-terminated byte string to be interpreted
str_endpointer to a pointer to character.
basebase of the interpreted integer value
Returns
returns the result of the conversion, unless the value would underflow or overflow. If the converted value falls out of range of corresponding return type, a range error occurs (setting errno to ERANGE) and LONG_MAX, LONG_MIN, LLONG_MAX or LLONG_MIN is returned. If no conversion can be performed, ​0​ is returned.

◆ strtoul()

unsigned long strtoul ( const char *__restrict  str,
char **__restrict  str_end,
int  base 
)

Interprets an unsigned long value in a byte string pointed to by str.

Interprets an unsigned long value in a byte string pointed to by str. Discards any whitespace characters (as identified by calling

See also
isspace()) until the first non-whitespace character is found, then takes as many characters as possible to form a valid base-n (where n=base) long number representation and converts them to an unsigned long value. The valid long value consists of the following parts:
 1) (optional) plus or minus sign
 2) (optional) prefix (0) indicating octal base (applies only when the base is 8 or ​0​)
 3) (optional) prefix (0x or 0X) indicating hexadecimal base (applies only when the base is
16 or ​0​) 4) a sequence of digits

The set of valid values for base is {0,2,3,...,36}. The set of valid digits for base-2 integers is {0,1}, for base-3 integers is {0,1,2}, and so on. For bases larger than 10, valid digits include alphabetic characters, starting from Aa for base-11 integer, to Zz for base-36 integer. The case of the characters is ignored.

If the value of base is ​0​, the numeric base is auto-detected: if the prefix is 0, the base is octal, if the prefix is 0x or 0X, the base is hexadecimal, otherwise the base is decimal.

If the minus sign was part of the input sequence, the numeric value calculated from the sequence of digits is negated as if by unary minus in the result type.

If the str is empty or does not have the expected form, no conversion is performed, and (if str_end is not NULL) the value of str is stored in the object pointed to by str_end.

Parameters
strpointer to the null-terminated byte string to be interpreted
str_endpointer to a pointer to character.
basebase of the interpreted integer value
Returns
returns the result of the conversion, unless the value would underflow or overflow. If the converted value falls out of range of corresponding return type, a range error occurs (setting errno to ERANGE) and LONG_MAX, LONG_MIN, LLONG_MAX or LLONG_MIN is returned. If no conversion can be performed, ​0​ is returned.

◆ strtoull()

unsigned long long strtoull ( const char *__restrict  str,
char **__restrict  str_end,
int  base 
)

Interprets an unsigned long long value in a byte string pointed to by str.

Interprets an unsigned long long value in a byte string pointed to by str. Discards any whitespace characters (as identified by calling

See also
isspace()) until the first non-whitespace character is found, then takes as many characters as possible to form a valid base-n (where n=base) long number representation and converts them to an unsigned long long value. The valid long value consists of the following parts:
 1) (optional) plus or minus sign
 2) (optional) prefix (0) indicating octal base (applies only when the base is 8 or ​0​)
 3) (optional) prefix (0x or 0X) indicating hexadecimal base (applies only when the base is
16 or ​0​) 4) a sequence of digits

The set of valid values for base is {0,2,3,...,36}. The set of valid digits for base-2 integers is {0,1}, for base-3 integers is {0,1,2}, and so on. For bases larger than 10, valid digits include alphabetic characters, starting from Aa for base-11 integer, to Zz for base-36 integer. The case of the characters is ignored.

If the value of base is ​0​, the numeric base is auto-detected: if the prefix is 0, the base is octal, if the prefix is 0x or 0X, the base is hexadecimal, otherwise the base is decimal.

If the minus sign was part of the input sequence, the numeric value calculated from the sequence of digits is negated as if by unary minus in the result type.

If the str is empty or does not have the expected form, no conversion is performed, and (if str_end is not NULL) the value of str is stored in the object pointed to by str_end.

Parameters
strpointer to the null-terminated byte string to be interpreted
str_endpointer to a pointer to character.
basebase of the interpreted integer value
Returns
returns the result of the conversion, unless the value would underflow or overflow. If the converted value falls out of range of corresponding return type, a range error occurs (setting errno to ERANGE) and LONG_MAX, LONG_MIN, LLONG_MAX or LLONG_MIN is returned. If no conversion can be performed, ​0​ is returned.

References isspace(), NULL, s, and ULLONG_MAX.

Referenced by strtoull_test().

Here is the caller graph for this function:

◆ system()

int system ( const char *  )

◆ wcstombs()

size_t wcstombs ( char *  __restrict,
const wchar_t __restrict,
size_t   
)

◆ wctomb()

int wctomb ( char *  ,
wchar_t   
)