1.
ParseNode是從堆中分配的。
指針數組作爲索引
typedef struct _ParseNode
{
int32_t num_child_;
struct _ParseNode** children_;//二級指針
} ParseNode;
2.
數組下表作爲索引
typedef struct _ParseNode
{
int32_t num_child_;
struct _ParseNode* children_;//一級指針
} ParseNode;
看上去第二種更省空間,省去了指針數組的空間,但是如果我要刪除children數組中的一個ParseNode,對應第一種方法只要free掉對應ParseNode再將對應的指針置爲NULL就行了。但是對於第二種方式因爲children當時申請時是一起申請的,不能free其中某些Node,從這個角度來講第一種更省空間。