malloc()                 Allocate Memory Block
 
 #include   <malloc.h>                   Required for declarations only
 
 char       *malloc(size);
 unsigned   size;                        Number of bytes to allocate
 
    malloc() allocates a block of 'size' bytes.
 
    Returns:    Pointer to allocated space.  Returns NULL (defined in
                <stdio.h>) if the space cannot be allocated.
 
      Notes:    Use free() to deallocate block allocated with malloc().
 
                The block allocated by malloc may be larger than 'size'
                bytes, due to space required for alignment and DOS
                housekeeping.  The space is guaranteed to be suitably
                aligned for storage of any type of object. (Use a cast on
                the return value if a pointer to a type other than char
                is required.)
 
  -------------------------------- Example ---------------------------------
 
    The following statements allocate space for 1000 bytes and then free
    the allocated space.
 
           #include <malloc.h>     /
           #include <stdio.h>      /* for printf and NULL */
 
           char *memptr;
 
           main()
           {
               if ((memptr = malloc(1000)) == NULL)
                    printf("not enough room to allocate memory\n");
               else {
                    .
                    .
                    free(memptr);
               }
           }

Seealso:



This page last updated on Fri Nov 30 10:48:32 MSK 2001
Copyright © 1992-2001, Vitaly Filatov, Moscow, Russia
Webmaster