delorie.com/djgpp/doc/libc/libc_551.html   search  
libc.a reference

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

malloc

Syntax

 
#include <stdlib.h>

void *malloc(size_t size);

Description

This function allocates a chunk of memory from the heap large enough to hold any object that is size bytes in length. This memory must be returned to the heap with free (see section free).

Note: this version of malloc is designed to reduce memory usage. A faster but less efficient version is available in the libc sources (`djlsr*.zip') in the file `src/libc/ansi/stdlib/fmalloc.c'.

Return Value

A pointer to the allocated memory, or NULL if there isn't enough free memory to satisfy the request.

Portability

ANSI/ISO C C89; C99
POSIX 1003.2-1992; 1003.1-2001

Example

 
char *c = (char *)malloc(100);


  webmaster     delorie software   privacy  
  Copyright © 2004     Updated Apr 2004