LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

TCPFreeMemory()

Why don't you need to use TCPFreeMemory() on strings allocated by GetTCPSystemErrorString() or GetTCPErrorString()?  If these functions allocate memory to the char *, don't I need to release it?  I'm getting 'Attempt to free pointer to memory not allocated by malloc() or calloc()' popups and I don't think that I should be.  I noticed that this function was not used in any of the TCP samples...
 
Orlan
0 Kudos
Message 1 of 4
(3,286 Views)
Hi Cosmo,
- The way I understand it: the TCP Error Strings and the TCP System Error Strings exits in your app. That the job of CVI. The only thing you do by calling the error functions is to "point" on the 1st char of the string. That's similar to some time.h functions in C like char *localtime(const time_t *tp): the function return always the same pointer where the string is stored.
- TCPFreeMemory() is used with TCP CVI functions that return an array of strings. See the help for GetAllTCPHostAddresses() for example
Regards,.

Message 2 of 4
(3,277 Views)

dilution is correct. The GetTCPSystemErrorString() expects a pointer to a user allocated char array. It does not allocate a char array for you, which is why you do not have to free it.

Bilal Durrani
NI
0 Kudos
Message 3 of 4
(3,247 Views)

Excellent,

  Thanx guys.  I'm already using it with GetAllTCPHostAddresses() and a note in the panel help files specifically reminds you to use TCPFreeMemory().  There was no mention of this function in the GetTCPErrorString() or GetTCPSystemErrorString() panel help files though.  I remember that CVI 7 didn't even have this function, but I assumed that NI changed the behavior and wanted TCPFreeMemory() to be used with all strings (and just forgot to mention that in the ...ErrorString() help files).  Perhaps I shouldn't read into the question so much!  Smiley Very Happy  Appreciate the help as always!

Orlan

0 Kudos
Message 4 of 4
(3,239 Views)