Created
February 5, 2022 22:02
-
-
Save kdrnic/0d121011fe1bdc32f489a24e58cc61ae to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
allocate a child and move down | |
parent -> null | |
^ | |
to | |
parent -> new child | |
^ | |
*/ | |
void typ_recur(struct typ **typ) | |
{ | |
(*typ)->child = typ_alloc(); | |
*typ = (*typ)->child; | |
} | |
/* | |
allocate a child and move down | |
parent -> old child | |
^ | |
to | |
parent -> new child -> old child | |
^ | |
*/ | |
void typ_recur2(struct typ **typ) | |
{ | |
struct typ *child = (*typ)->child; | |
(*typ)->child = typ_alloc(); | |
(*typ)->child->child = child; | |
*typ = (*typ)->child; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment