Broadcom | Onsite | Read characters from stream
Anonymous User
161

Given
Struct node {
int data[32];
int data_len;
Struct node* next;
}

A API get_stream() returns stream of bytes. Implement buildNodeList() API and return the linked list as shown below :
Each linked list node can ONLY store 32 bytes of data. No holes. Fill every node greedly upto 32 bytes.

get_stream() -> first time returns 50 bytes of data
get_stream()-> second time returns 20 bytes of data
get_stream() finally returns null
return linked list [32]->[32]->6

uint8_t* cur_data;

Struct node* buildNodeList() {

	while(cur_data = get_stream(&cur_data_len)) {
	// implement here and build a linked list
	
	
	}

}

How do we go about this ? Appreciate any thought process especially when manupulating offsets and reading data from stream

Comments (1)