Skip to content

Instantly share code, notes, and snippets.

@windy1
Last active April 19, 2017 19:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save windy1/c8878017911bf3009e2faa9207a3badf to your computer and use it in GitHub Desktop.
Save windy1/c8878017911bf3009e2faa9207a3badf to your computer and use it in GitHub Desktop.
void onFinish(SomeData *data) {
callback(data);
if (data->myData) {
// "pointer being freed was not allocated"
// debugger says address is different from before callback
free(data->myData);
}
}
void callback(SomeData *data) {
doStuff(*data);
}
void doStuff(SomeData data) {
char *buffer = (char*) malloc(numBytes);
memcpy(buffer, data.myData, numBytes);
// ...do stuff with buffer...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment