> struct Foo {
>     LWLock lock;
>     size_t size;
>     Bar data[];
> };
>
> * To create a few of these, I have to provide a lock name to the
> callback, that's the "reusing the same callback" part again
> * And then there's the question of initialization. Either I leave it
> to the caller after returning from GetNamedDSHash using the lock,

"caller after returning from GetNamedDSHash" <- do you mean
GetNamedDSMSegment ?

> or somehow I have to tell the initialization callback the array size -
> even if I can calculate the size based on a GUC,

```
typedef struct Bar {
int f1;
int f2;
} Bar;

typedef struct Foo {
LWLock lock;
size_t size;
Bar data[];
} Foo;

foo_state = GetNamedDSMSegment("Foo",

offsetof(Foo, data) + BAR_ARRAY_SIZE * sizeof(int),
                                                            foo_init_state,
                                                            &found);
```

wouldn't the above be sufficient to create a DSM segment containing
a flexible array?

--
Sami Imseih
Amazon Web Services (AWS)


Reply via email to