alloc mem before using... :)

This commit is contained in:
matthias.ringwald 2009-07-16 19:09:17 +00:00
parent 4b7a7cf2b5
commit c13e4b9a30

View File

@ -73,17 +73,17 @@ int bt_open(){
return -1;
}
// init state machine
btstack_connection->state = SOCKET_W4_HEADER;
btstack_connection->bytes_read = 0;
btstack_connection->bytes_to_read = 2;
// register with run loop
btstack_connection = malloc( sizeof(connection_t));
if (btstack_connection == NULL) return -1;
btstack_connection->ds.fd = btstack_socket;
btstack_connection->ds.process = btstack_socket_process;
run_loop_add(&btstack_connection->ds);
// init state machine
btstack_connection->state = SOCKET_W4_HEADER;
btstack_connection->bytes_read = 0;
btstack_connection->bytes_to_read = 2;
return 0;
}