Skip to content

Commit 2b69afb

Browse files
committed
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>
1 parent c1da728 commit 2b69afb

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-0
lines changed

src/fe_utils/simple_list.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,3 +192,44 @@ simple_ptr_list_destroy(SimplePtrList *list)
192192
cell = next;
193193
}
194194
}
195+
196+
/*
197+
* Add to an oid_string list
198+
*/
199+
void
200+
simple_oid_string_list_append(SimpleOidStringList *list, Oid oid, const char *str)
201+
{
202+
SimpleOidStringListCell *cell;
203+
204+
cell = (SimpleOidStringListCell *)
205+
pg_malloc(offsetof(SimpleOidStringListCell, str) + strlen(str) + 1);
206+
207+
cell->next = NULL;
208+
cell->oid = oid;
209+
strcpy(cell->str, str);
210+
211+
if (list->tail)
212+
list->tail->next = cell;
213+
else
214+
list->head = cell;
215+
list->tail = cell;
216+
}
217+
218+
/*
219+
* Destroy an oid_string list
220+
*/
221+
void
222+
simple_oid_string_list_destroy(SimpleOidStringList *list)
223+
{
224+
SimpleOidStringListCell *cell;
225+
226+
cell = list->head;
227+
while (cell != NULL)
228+
{
229+
SimpleOidStringListCell *next;
230+
231+
next = cell->next;
232+
pg_free(cell);
233+
cell = next;
234+
}
235+
}

src/include/fe_utils/simple_list.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,19 @@ typedef struct SimplePtrList
5555
SimplePtrListCell *tail;
5656
} SimplePtrList;
5757

58+
typedef struct SimpleOidStringListCell
59+
{
60+
struct SimpleOidStringListCell *next;
61+
Oid oid;
62+
char str[FLEXIBLE_ARRAY_MEMBER]; /* null-terminated string here */
63+
} SimpleOidStringListCell;
64+
65+
typedef struct SimpleOidStringList
66+
{
67+
SimpleOidStringListCell *head;
68+
SimpleOidStringListCell *tail;
69+
} SimpleOidStringList;
70+
5871
extern void simple_oid_list_append(SimpleOidList *list, Oid val);
5972
extern bool simple_oid_list_member(SimpleOidList *list, Oid val);
6073
extern void simple_oid_list_destroy(SimpleOidList *list);
@@ -68,4 +81,7 @@ extern const char *simple_string_list_not_touched(SimpleStringList *list);
6881
extern void simple_ptr_list_append(SimplePtrList *list, void *ptr);
6982
extern void simple_ptr_list_destroy(SimplePtrList *list);
7083

84+
extern void simple_oid_string_list_append(SimpleOidStringList *list, Oid oid, const char *str);
85+
extern void simple_oid_string_list_destroy(SimpleOidStringList *list);
86+
7187
#endif /* SIMPLE_LIST_H */

src/tools/pgindent/typedefs.list

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2747,6 +2747,8 @@ SimpleActionListCell
27472747
SimpleEcontextStackEntry
27482748
SimpleOidList
27492749
SimpleOidListCell
2750+
SimpleOidStringList
2751+
SimpleOidListStringCell
27502752
SimplePtrList
27512753
SimplePtrListCell
27522754
SimpleStats

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy