-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added deep-copy functions tosc_copy_message and tosc_copy_bundle #4
base: master
Are you sure you want to change the base?
Conversation
Hi @neonsoftware, thanks a lot for the PR! I can certainly see the usecase for a deep copy function. In order to simplify what you've proposed, what do you think of something like:
|
Hi @mhroth. |
let me know if the PR is to be re-done or the change will be on your side |
I realise that this PR is dragging on, I'm sorry for that. Could you write a code snippet for how you intend to use this function? This function is now only saving you two lines of code (one to copy the buffer, one to parse the buffer). I'm thinking that the usecase is to copy the OSC buffer away from the networking code and onto some other queue. To me it feels like if that's what you are trying to accomplish, then, it seems to me, you wouldn't need this kind of a deep copy function. You could just call I hope that you don't misunderstand my intentions. I really appreciate the PR, and I'd like to balance that with keeping the library, well, tiny ;) |
No problem at all ! 👍 But here is the current usage context, absolutely, please feel free to see where they are used, here in this repo, for example, search
int kian_get_next_message(tosc_message *dst)
{
tosc_message *next_msg = NULL;
if (!kian_bag.is_initialized)
kian_init();
next_msg = kian_next_message();
if (next_msg != NULL) {
tosc_copy_message(dst, next_msg);
return 1;
}
return 0;
} if I substitute I would still need also a tosc_parseMessage, please feel me if I'm wrong int kian_get_next_message(tosc_message *dst)
{
tosc_message *next_msg = NULL;
if (!kian_bag.is_initialized)
kian_init();
next_msg = kian_next_message();
if (next_msg != NULL) {
memcpy(dst->buffer, next_msg-> buffer, dst->len);
tosc_parseMessage(dst, dst->buffer, dst->len);
return 1;
}
return 0;
} Two aspects :
|
Added two simple deep copy functions.
As you can see the memory allocation is completely in charge of the caller (as warned within the function comments), which results in the functions being very simple, which I guess might make them quite light to maintain in the future.
Anyways please feel absolutely free to close if you don't find them useful in the API.
(I can move this feature in the client)
Please also feel free to return any feedback or demand for any change or modify it.
Cheers again 👍