Skip to content

Instantly share code, notes, and snippets.

@s0cks

s0cks/example.c Secret

Created September 12, 2016 17:06
typedef struct{
int count;
} base;
typedef struct{
base root;
int multiplier;
} leaf;
root* leaf_new(int multiplier){
leaf* l = malloc(sizeof(leaf));
l->root.count = 0;
l->multiplier = multiplier;
return &l->root;
}
void leaf_set_multiplier(root* r, int multiplier){
leaf* l = container_of(r, leaf, root);
l->multiplier = multiplier;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment