I am writing an exteral which is using SendCardMessage(). I know the ownership of the memory is only passed to rev if you use malloc() etc...
What I want to know is.. If I malloc 100 bytes to a buffer for my message to return and only sprintf about 50 chars into said buffer then SendCardMessage(buffer,result) is the whole 100 bytes owned by revolution or only the 50 bytes that were actually used?
I ask this because in windows task manager, The memory usage of the rev ide keeps climbing when I use my external.
Memory Ownership SendCardMessage Malloc() Sprintf()
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- VIP Livecode Opensource Backer
- Posts: 3581
- Joined: Mon Jan 22, 2007 7:36 am
- Location: Berkeley, CA, US
- Contact:
Neil-
Not sure about this, but I think the best thing to do might be to use istrdup to create a copy of the buffer in rev-manageable memory space and then free the memory you malloced, i.e.,
Not sure about this, but I think the best thing to do might be to use istrdup to create a copy of the buffer in rev-manageable memory space and then free the memory you malloced, i.e.,
Code: Select all
int *r_error;
char *rbuffer, *buffer;
buffer = malloc(100);
sprintf(buffer, "%s", whatever);
istrdup(rbuffer, buffer);
free(buffer);
SendCardMessage(rbuffer, &r_error);