DACS_GetLock do I need to explicitly free the memory for

vishal.anand
vishal.anand Contributor
edited June 19 in UPA

In the following exmaple :

if (DACS_GetLock(30, pcTypePtr, &lock1Ptr, &lock1Len, &dacsError) == DACS_FAILURE)

{

if (DACS_perror(dacsErrorBuffer, sizeof(dacsErrorBuffer), (unsigned char *)"DACS_GetLock() failed with error", &dacsError) == DACS_SUCCESS)

{

printf("%s\n", dacsErrorBuffer);

}

else

{

printf("DACS_GetLock() failed\n");

}

return;

}

using lockPtr to add permData.Do I need to explicitly free(lock1Ptr) after encoding into RsslMsg and using rsslWrite or rsslWrite automatically will deallocate memory as it does for RsslBuffer after writing?

Is there any example that talks about it where we actually use DACS_GetLock and do rsslWrite ?

Answers

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    @vishal.anand

    Thank you for reaching out to us.

    DACS Lock API and ETA API are different APIs.

    rsslWrite will manage the buffer acquired by the rsslGetBuffer method.

    If the buffer is not used or the rsslWrite function call fails, the buffer must be released back into the pool to ensure proper reuse and cleanup by calling the rsslReleaseBuffer method. If the buffer is successfully passed to rsslWrite (not calling the rsslReleaseBuffer), when flushed to the network the buffer will be returned to the correct pool by the transport.

    The memory reserved by the DACS_GetLock method doesn't relate to the ETA managed buffer. Therefore, you need to call the free method to free the DACS lock memory after encoding it into the the ETA buffer.

    You need to encode the DACS lock data into the ETA buffer.