I came across piece of code that uses container_of.
typedef struct api_1 api_2;
typedef void (*api_set)(api_2 *api, int a);
struct api_1{
api_set set;
};
typedef struct{
api_2 api;
int value;
} api_p_t;
void set(api_2 *api, int a){
api_p_t *priv_api = container_of(api, api_p_t, api);
priv_api->value = a;
}
Please explain me, why "container_of(api, api_p_t, api)" uses parameter "api" twice? Is it some kind of polymorphic behaviour?