Code using GetNamedDSHash() to retrieve a dshash table may also want to
limit its size, but there is actually no easy way to do so because the
dsa_area of a hash table is hidden within dshash.c.
This commit adds dshash_get_dsa_area() to close the gap, which returns
the dsa_area for a given dshash_table. The DSA area retrieved can then
be passed to dsa_set_size_limit(), to limit its size. This accessor
routine also opens the door for allocating additional objects in the
same DSA area as a hash table, which may be useful for some.
Author: Sami Imseih <samimseih@gmail.com>
Discussion: https://postgr.es/m/CAA5RZ0tKfCVqFnMZtavM42H63ha2Haf_C4mbJNWqkaW30cPW1w@mail.gmail.com
pfree(hash_table);
}
+/*
+ * Get the DSA area used by this hash table.
+ */
+dsa_area *
+dshash_get_dsa_area(dshash_table *hash_table)
+{
+ Assert(hash_table->control->magic == DSHASH_MAGIC);
+
+ return hash_table->area;
+}
+
/*
* Get a handle that can be used by other processes to attach to this hash
* table.
dshash_table_handle handle,
void *arg);
extern void dshash_detach(dshash_table *hash_table);
+extern dsa_area *dshash_get_dsa_area(dshash_table *hash_table);
extern dshash_table_handle dshash_get_hash_table_handle(dshash_table *hash_table);
extern void dshash_destroy(dshash_table *hash_table);