GBDK 2020 Docs API Documentation for GBDK 2020

Macros | Functions
stdlib.h File Reference
`#include <types.h>`

Go to the source code of this file.

## Macros
#define | __reentrant

## Functions
void | exit (int status) NONBANKED
int | abs (int i)
long | labs (long num)
int | atoi (const char *s)
long | atol (const char *s)
char * | itoa (int n, char *s)
char * | utoa (unsigned int n, char *s)
char * | ltoa (long n, char *s)
char * | ultoa (unsigned long n, char *s)
void * | calloc (size_t nmemb, size_t size)
void * | malloc (size_t size)
void * | realloc (void *ptr, size_t size)
void | free (void *ptr)
void * | bsearch (const void *key, const void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *) __reentrant)
void | qsort (void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *) __reentrant)

## Macro Definition Documentation

## ◆ __reentrant

#define __reentrant

file stdlib.h 'Standard library' functions, for whatever that means.

## Function Documentation

## ◆ exit()

void exit | ( | int | status | ) |

Causes normal program termination and the value of status is returned to the parent. All open streams are flushed and closed.

## ◆ abs()

int abs | ( | int | i | ) |

Returns the absolute value of int i

Parameters

  i | Int to obtain absolute value of

If i is negative, returns -i; else returns i.

## ◆ labs()

long labs | ( | long | num | ) |

Returns the absolute value of long int num

Parameters

  num | Long integer to obtain absolute value of

## ◆ atoi()

int atoi | ( | const char * | s | ) |

Converts an ASCII string to an int

Parameters

  s | String to convert to an int

The string may be of the format

[\s]*[+-][\d]+[\D]*

i.e. any number of spaces, an optional + or -, then an arbitrary number of digits.

The result is undefined if the number doesnt fit in an int.

Returns: Int value of string

## ◆ atol()

long atol | ( | const char * | s | ) |

Converts an ASCII string to a long.

Parameters

  s | String to convert to an long int

See also
  atoi()

Returns: Long int value of string

## ◆ itoa()

char* itoa | ( | int | n,
|  | char * | s
| ) |  |

Converts an int into a base 10 ASCII string.

Parameters

  n | Int to convert to a string
  s | String to store the converted number

Returns: Pointer to converted string

## ◆ utoa()

char* utoa | ( | unsigned int | n,
|  | char * | s
| ) |  |

Converts an unsigned int into a base 10 ASCII string.

Parameters

  n | Unsigned Int to convert to a string
  s | String to store the converted number

Returns: Pointer to converted string

## ◆ ltoa()

char* ltoa | ( | long | n,
|  | char * | s
| ) |  |

Converts a long into a base 10 ASCII string.

Parameters

  n | Long int to convert to a string
  s | String to store the converted number

Returns: Pointer to converted string

## ◆ ultoa()

char* ultoa | ( | unsigned long | n,
|  | char * | s
| ) |  |

Converts an unsigned long into a base 10 ASCII string.

Parameters

  n | Unsigned Long Int to convert to a string
  s | String to store the converted number

Returns: Pointer to converted string

## ◆ calloc()

void* calloc | ( | size_t | nmemb,
|  | size_t | size
| ) |  |

Memory allocation functions

## ◆ malloc()

void* malloc | ( | size_t | size | ) |

## ◆ realloc()

void* realloc | ( | void * | ptr,
|  | size_t | size
| ) |  |

## ◆ free()

void free | ( | void * | ptr | ) |

## ◆ bsearch()

void* bsearch | ( | const void * | key,
|  | const void * | base,
|  | size_t | nmemb,
|  | size_t | size,
|  | int(*)(const void *, const void *) __reentrant | compar
| ) |  |

search a sorted array of nmemb items

Parameters

  key | Pointer to object that is the key for the search
  base | Pointer to first object in the array to search
  nmemb | Number of elements in the array
  size | Size in bytes of each element in the array
  compar | Function used to compare two elements of the array

Returns: Pointer to array entry that matches the search key. If key is not found, NULL is returned.

## ◆ qsort()

void qsort | ( | void * | base,
|  | size_t | nmemb,
|  | size_t | size,
|  | int(*)(const void *, const void *) __reentrant | compar
| ) |  |

Sort an array of nmemb items

Parameters

  base | Pointer to first object in the array to sort
  nmemb | Number of elements in the array
  size | Size in bytes of each element in the array
  compar | Function used to compare and sort two elements of the array

d
void d
Definition: gb.h:453