int *inorder_rec( struct node *root, int *start, int *end ) { if ( !root ) return start; start = inorder_rec( root->left, start, end ); if ( !start || start + 1 > end ) return NULL; *start++ = root->value; assert( start <= end ); return inorder_rec( root->right, start, end ); } struct values inorder( struct heap *heap, struct node *root ) { struct values res = { .data = ( int * ) heap->start }; int *end = inorder_rec( root, res.data, ( int * ) heap->end ); if ( end ) { res.length = end - res.data; heap->start = ( char * ) end; } else res.data = NULL; return res; }