stdlib.h File Reference

Interface: reduced standard C library. More...

#include <mem.h>
Include dependency graph for stdlib.h:

Go to the source code of this file.

Functions

void * calloc (size_t nmemb, size_t size)
 allocate and return pointer to initialized memory
 
void * malloc (size_t size)
 allocate and return pointer to uninitialized memory
 
void free (void *ptr)
 return the allocated memory to memory management.
 
long int random (void)
 generate a random number
 
void srandom (unsigned int seed)
 seed the random number generator
 

Detailed Description

Interface: reduced standard C library.

This file describes the public programming interface for 
memory management services and random number services
Author
Markus L. Noga marku.nosp@m.s@no.nosp@m.ga.de

Definition in file stdlib.h.

Function Documentation

◆ calloc()

void * calloc ( size_t  nmemb,
size_t  size 
)
extern

allocate and return pointer to initialized memory

calloc() allocates memory for an array of {nmemb} elements of {size} bytes each and returns a pointer to the allocated memory. The memory is filled with zero values.

Parameters
nmembthe number of members to allocate
sizethe size (in bytes) of each member to be allocated
Returns
a pointer to the allocated memory (or NULL if failed)

NOTE: content of the returned memory is initialized by this routine

Bug:
multiplication overflow (elements * size) is not detected

◆ free()

void free ( void *  ptr)
extern

return the allocated memory to memory management.

free() frees the memory space pointed to by {ptr}, which must have been returned by a previous call to malloc(), or calloc(). Other- wise, or if free(ptr) has already been called before, undefined behaviour occurs. If ptr is NULL, no operation is performed.

Parameters
ptra pointer to previously allocated memory
Returns
Nothing

◆ malloc()

void * malloc ( size_t  size)
extern

allocate and return pointer to uninitialized memory

malloc() allocates {size} bytes of memory and returns a pointer to it.

Parameters
sizethe number of bytes of memory to be allocated
Returns
a pointer to the allocated memory (or NULL if failed)

NOTE: content of the returned memory is not initialized by this routine

◆ random()

long int random ( void  )
extern

generate a random number

The random() function returns successive pseudo-random numbers

Returns
a random number in the range from 0 to RAND_MAX

◆ srandom()

void srandom ( unsigned int  seed)
extern

seed the random number generator

The srandom() function sets its argument as the seed for a new sequence of pseudo-random integers to be returned by random(). These sequences are repeatable by calling srandom() with the same seed value. If no seed value is provided, the random() function is automatically seeded with a value of 1.

Parameters
seed
Returns
Nothing

brickOS is released under the Mozilla Public License.
Original code copyright 1998-2005 by the authors.

Generated for brickOS C++ by doxygen 1.9.8