free

From RAD Studio
Jump to: navigation, search

Go Up to alloc.h Index


Header File

alloc.h, stdlib.h

Prototype

void free(void *block);

Description

Frees allocated block.

free deallocates a memory block allocated by a previous call to calloc, malloc, or realloc.

Return Value

None.

Portability

POSIX ANSI C ANSI C++ Win32 Win64 macOS
free + + + +

Example

#include <string.h>
#include <stdio.h>
#include <alloc.h>

int main(void) {
    char *str;
    /* allocate memory for string */
    str = (char *) malloc(10);
    /* copy "Hello" to string */
    strcpy(str, "Hello");
    /* display string */
    printf("String is %s\n", str);
    /* free memory */
    free(str);
    return 0;
}