Quantcast
Channel: LabWindows/CVI topics
Viewing all articles
Browse latest Browse all 5372

"sizeof" problem

$
0
0
void UDPchannelsend(uint8_t* msg_to_send)
{
int error = 0;
int *msg;
//uint8_t size = sizeof(uint8_t *);
//uint8_t msg[40];
msg= (int*)calloc(sizeof(msg_to_send), sizeof(int));
memcpy(msg,msg_to_send,sizeof(msg_to_send));

errChk(UDPWrite (wholePODchannel, UDPwritePort, UDP_DestAddress, msg, sizeof(msg)));
free (msg);
Error:
if (error < 0)
MessagePopup("Error", GetGeneralErrorString(error));
}

hey,

i'm getting some problems with "sizeof" in the calloc func.

i'm trying to create a generic UDPSend function, with a pointer to array argument, but with no luck.
my msg_to_send is 34 bytes (i can verify in the watch expression), but my "msg" after the calloc is only 4 bytes.

i tried to check the size that "sizeof" is giving, and hence the line:

uint8_t size = sizeof(uint8_t *);

 no matter what type i insert in the brackets, i always get " 4 ".

any thoughts?




 


Viewing all articles
Browse latest Browse all 5372

Trending Articles