Share this page

# Example: return

The following example allocates a memory buffer using the malloc function. If allocation is unsuccessful, the function returns with a -1 value. If successful, the function continues and returns 0 at completion.

        #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 = %.8Xh", buf);

        // Do something with the buffer here ...

        // Now free the buffer

        free(buf);

    Example: Output:
    Action.c(11): Memory allocated - buffer address = 007B9D88h

Tips to improve your search results... VuGen Function Reference Version 25.1-25.3 Function Reference 25.1-25.3 All View Local Help Center View Online Help Center Version: