This is no different than any other use of sizeof ; he will evaluate the size of his operand. sizeof based on compile-time information, 1 so it doesnβt matter that ret just been declared.
This idiom is the preferred way to use malloc . If you used be_node *ret = malloc(sizeof(be_node)) , then think about what happens if you change the ret type to a later date. If you forget to replace both use cases with " be_node ", you will be_node subtle bug.
<Sub> 1. Except with variable length arrays.
source share