Main Page   Data Structures   File List   Data Fields   Globals   Related Pages  

include/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. More...

void * malloc (size_t size)
 allocate and return pointer to uninitialized memory. More...

void free (void *ptr)
 return the allocated memory to memory management. More...

long int random (void)
 generate a random number. More...

void srandom (unsigned int seed)
 seed the random number generator. More...


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 <markus@noga.de>

Definition in file stdlib.h.


Function Documentation

void* calloc size_t    nmemb,
size_t    size
 

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:
nmemb  the number of members to allocate
size  the 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

void free void *    ptr
 

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:
ptr  a pointer to previously allocated memory
Returns:
Nothing

void* malloc size_t    size
 

allocate and return pointer to uninitialized memory.

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

Parameters:
size  the 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

long int random void   
 

generate a random number.

The random() function returns successive pseudo-random numbers

Returns:
a random number in the range from 0 to RAND_MAX

void srandom unsigned int    seed
 

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-2002 by the authors.

Generated on Tue Dec 10 00:09:02 2002 for brickOS C by doxygen 1.2.15