Skip to content

Instantly share code, notes, and snippets.

@kellabyte kellabyte/output.log Secret
Created Feb 6, 2017

What would you like to do?
POINTERS 1:0x7fc4e1002c00 0x7fc4e1002c00
POINTERS 2:0x7fc4e1002c00 0x10d2fbc3b <--- WHY IS THIS POINTER WRONG?
typedef struct connection {
uv_tcp_t stream;
uv_buf_t buffer;
} connection;
void uv_stream_on_alloc(uv_handle_t* client, size_t suggested_size, uv_buf_t* buf) {
connection* conn = (connection*)client->data;
char *buffer = (char *)malloc(suggested_size)
*buf = uv_buf_init(buffer, suggested_size);
conn->buffer = *buf;
printf("POINTERS 1:%p\t%p\n", conn->buffer.base, buf->base);
void uv_stream_on_read(uv_stream_t* stream, ssize_t nread, const uv_buf_t* buf) {
connection* conn = (connection*)client->data;
printf("POINTERS 2:%p\t%p\n", conn->buffer.base, buf->base);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.