diff options
author | Andrew Dunstan <andrew@dunslane.net> | 2025-03-28 18:10:24 -0400 |
---|---|---|
committer | Andrew Dunstan <andrew@dunslane.net> | 2025-04-04 16:01:22 -0400 |
commit | 2b69afbe50d5e39cc7d9703b3ab7acc4495a54ea (patch) | |
tree | 6e100036a280609b83eb0f0a2bf930bc18af290c /src/fe_utils | |
parent | c1da7281060d646f863e920a1aac3b9dbc997672 (diff) | |
download | postgresql-2b69afbe50d5e39cc7d9703b3ab7acc4495a54ea.tar.gz postgresql-2b69afbe50d5e39cc7d9703b3ab7acc4495a54ea.zip |
add new list type simple_oid_string_list to fe-utils/simple_list
This type contains both an oid and a string.
This will be used in forthcoming changes to pg_restore.
Author: Andrew Dunstan <andrew@dunslane.net>
Diffstat (limited to 'src/fe_utils')
-rw-r--r-- | src/fe_utils/simple_list.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/fe_utils/simple_list.c b/src/fe_utils/simple_list.c index 483d5455594..b0686e57c4a 100644 --- a/src/fe_utils/simple_list.c +++ b/src/fe_utils/simple_list.c @@ -192,3 +192,44 @@ simple_ptr_list_destroy(SimplePtrList *list) cell = next; } } + +/* + * Add to an oid_string list + */ +void +simple_oid_string_list_append(SimpleOidStringList *list, Oid oid, const char *str) +{ + SimpleOidStringListCell *cell; + + cell = (SimpleOidStringListCell *) + pg_malloc(offsetof(SimpleOidStringListCell, str) + strlen(str) + 1); + + cell->next = NULL; + cell->oid = oid; + strcpy(cell->str, str); + + if (list->tail) + list->tail->next = cell; + else + list->head = cell; + list->tail = cell; +} + +/* + * Destroy an oid_string list + */ +void +simple_oid_string_list_destroy(SimpleOidStringList *list) +{ + SimpleOidStringListCell *cell; + + cell = list->head; + while (cell != NULL) + { + SimpleOidStringListCell *next; + + next = cell->next; + pg_free(cell); + cell = next; + } +} |