I have a struct
, let's call it struct foo
, to which I'd like to add an atomic_flag
variable. So far, I've been calloc
ing the struct given that it mostly needs to be zero initialized.
How should I be initializing the atomic_flag
member?
struct foo{
//...
atomic_flag a_flg;
//...
};
struct foo *foop = calloc(1,sizeof *foop);
if(!foop) return -1;
//should I be giving up `calloc` (/`malloc`+`memset`) in favor of `malloc`+this?
*foop = (struct foo){ ATOMIC_FLAG_INIT };
Edit:
I have found this related DR#421 by Jens Gustedt that proposes that zero/default-initialization be made to just work for atomic_flag
s. How can I find out if it's been accepted?