sizeof rr
is the size of the pointer. But you need to allocate enough memory for the struct. Use
sizeof *rr
or
sizeof(rr_scheduler)
to do that.
As it stands in your program, you don't allocate enough memory for the struct and so write beyond the end of the block, thus corrupting the heap.
It also seems odd to initialise rr
to NULL
and then immediately assign to it. I would write that as
rr_scheduler* rr = malloc(sizeof *rr);