Reputation: 1128
I need to hold a dynamic array of structs.
The types are defined like this. I'm not able to change those, because they are given by a library called flint (library for fast number theory).
typedef struct
{
mp_ptr coeffs;
slong alloc;
slong length;
nmod_t mod;
} nmod_poly_struct;
typedef nmod_poly_struct nmod_poly_t[1];
and my struct is defined like this:
typedef struct {
mp_limb_t D;
mp_limb_t length;
nmod_poly_t *s;
} she_key_symmetric_t;
So my problem is to hold a set of nmod_poly_t objects. I initialize them and want so store them in the array.
nmod_poly_t poly;
nmod_poly_init(poly);
she_key_symmetric_t key;
// init and stuff
key.s[0] = poly; // This line does not work, because
// it always says "array type 'nmod_poly_t' (aka
// 'nmod_poly_struct[1]') is not assignable"
In the next step I have to get the values back out of the array
she_key_symmetric_t key;
// fully initialized key
nmod_poly_t poly = key.s[0];
So how do I need to declare my dynamic array s to store my strucs inside it?
Thanks in advance
Upvotes: 1
Views: 115
Reputation: 2373
Following will work, assuming memory allocated properly for key.s
and initialized
nmod_poly_t poly;
poly[0] =key.s[0][0];
Upvotes: 1