Example: malloc

The following example uses malloc to allocate a buffer of length 1024.

#include <malloc.h>
    char * buf;
    if ((buf = (char *)malloc(1024 * sizeof(char))) == NULL) {
        lr_output_message ("Insufficient memory available");
        return -1;
    }
    lr_output_message ("Memory allocated . Buffer address = %.8x", buf);
    // Do something with the buffer here ...
    // Now free the buffer
    free(buf);
Example: Output:
Action.c(11): Memory allocated. Buffer address = 007b9d88