-
Notifications
You must be signed in to change notification settings - Fork 266
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
why use raft_server_t* in all functions? instead just use raft_server_t #5
Comments
Hey that's a good question The one and only reason why raft_server_t is void* is because of encapsulation. A void* typedef means I can do whatever with my implementation and keep the details private. There's no other reason for me using the void* typedef Why do I use raft_server_t* instead of raft_server_t, which is a void* pointer already? Why don't I use just void* in every function prototype? So if I'm effectively using void* * for all my raft_server_t* references why does it work? Hope this makes sense. In the last month I've found a better technique for encapsulation. If you're interested you might want to look at the heap_t typedef in https://github.com/willemt/heap/blob/master/heap.h |
Hi Willemt,
I like your work so much. I have a question here:
void raft_set_current_term(raft_server_t* me_, int term)
{
raft_server_private_t* me = (void*)me_;
me->current_term = term;
}
Like this,
why not just use raft_server_t, since it is already void*.
I don't quite understand. Could you please tell me?
Thank you
The text was updated successfully, but these errors were encountered: