PostgreSQL Source Code  git master
ilist.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  dlist_node
 
struct  dlist_head
 
struct  dlist_iter
 
struct  dlist_mutable_iter
 
struct  slist_node
 
struct  slist_head
 
struct  slist_iter
 
struct  slist_mutable_iter
 

Macros

#define DLIST_STATIC_INIT(name)   {{&(name).head, &(name).head}}
 
#define SLIST_STATIC_INIT(name)   {{NULL}}
 
#define dlist_check(head)   ((void) (head))
 
#define slist_check(head)   ((void) (head))
 
#define dlist_container(type, membername, ptr)
 
#define dlist_head_element(type, membername, lhead)
 
#define dlist_tail_element(type, membername, lhead)
 
#define dlist_foreach(iter, lhead)
 
#define dlist_foreach_modify(iter, lhead)
 
#define dlist_reverse_foreach(iter, lhead)
 
#define slist_container(type, membername, ptr)
 
#define slist_head_element(type, membername, lhead)
 
#define slist_foreach(iter, lhead)
 
#define slist_foreach_modify(iter, lhead)
 

Typedefs

typedef struct dlist_node dlist_node
 
typedef struct dlist_head dlist_head
 
typedef struct dlist_iter dlist_iter
 
typedef struct dlist_mutable_iter dlist_mutable_iter
 
typedef struct slist_node slist_node
 
typedef struct slist_head slist_head
 
typedef struct slist_iter slist_iter
 
typedef struct slist_mutable_iter slist_mutable_iter
 

Functions

void slist_delete (slist_head *head, slist_node *node)
 
static void dlist_init (dlist_head *head)
 
static bool dlist_is_empty (dlist_head *head)
 
static void dlist_push_head (dlist_head *head, dlist_node *node)
 
static void dlist_push_tail (dlist_head *head, dlist_node *node)
 
static void dlist_insert_after (dlist_node *after, dlist_node *node)
 
static void dlist_insert_before (dlist_node *before, dlist_node *node)
 
static void dlist_delete (dlist_node *node)
 
static dlist_nodedlist_pop_head_node (dlist_head *head)
 
static void dlist_move_head (dlist_head *head, dlist_node *node)
 
static void dlist_move_tail (dlist_head *head, dlist_node *node)
 
static bool dlist_has_next (dlist_head *head, dlist_node *node)
 
static bool dlist_has_prev (dlist_head *head, dlist_node *node)
 
static dlist_nodedlist_next_node (dlist_head *head, dlist_node *node)
 
static dlist_nodedlist_prev_node (dlist_head *head, dlist_node *node)
 
static void * dlist_head_element_off (dlist_head *head, size_t off)
 
static dlist_nodedlist_head_node (dlist_head *head)
 
static void * dlist_tail_element_off (dlist_head *head, size_t off)
 
static dlist_nodedlist_tail_node (dlist_head *head)
 
static void slist_init (slist_head *head)
 
static bool slist_is_empty (slist_head *head)
 
static void slist_push_head (slist_head *head, slist_node *node)
 
static void slist_insert_after (slist_node *after, slist_node *node)
 
static slist_nodeslist_pop_head_node (slist_head *head)
 
static bool slist_has_next (slist_head *head, slist_node *node)
 
static slist_nodeslist_next_node (slist_head *head, slist_node *node)
 
static void * slist_head_element_off (slist_head *head, size_t off)
 
static slist_nodeslist_head_node (slist_head *head)
 
static void slist_delete_current (slist_mutable_iter *iter)
 

Macro Definition Documentation

◆ dlist_check

#define dlist_check (   head)    ((void) (head))

◆ dlist_container

#define dlist_container (   type,
  membername,
  ptr 
)
Value:
AssertVariableIsOfTypeMacro(((type *) NULL)->membername, dlist_node), \
((type *) ((char *) (ptr) - offsetof(type, membername))))
#define AssertVariableIsOfTypeMacro(varname, typename)
Definition: c.h:966
#define offsetof(type, field)
Definition: c.h:727

Definition at line 496 of file ilist.h.

Referenced by addItemsToLeaf(), AssertChangeLsnOrder(), AssertTXNLsnOrder(), AtEOXact_SMgr(), autovac_balance_cost(), cache_reduce_memory(), CatCacheInvalidate(), CleanupBackend(), computeLeafRecompressWALData(), CountChildren(), dataBeginPlaceToPageLeaf(), dataPlaceToPageLeafRecompress(), dataPlaceToPageLeafSplit(), do_autovacuum(), do_start_worker(), dsm_attach(), dsm_find_mapping(), FindLockCycleRecurse(), GenerationReset(), GenerationStats(), get_flush_position(), GetBlockerStatusData(), ginVacuumPostingTreeLeaf(), HandleChildCrash(), HandleParallelMessages(), InvalidateConstraintCacheCallBack(), launch_worker(), leafRepackItems(), logical_heap_rewrite_flush_mappings(), mXactCacheGetById(), mXactCacheGetBySet(), mXactCachePut(), PlanCacheObjectCallback(), PlanCacheRelCallback(), PostmasterMarkPIDForWorkerNotify(), processCancelRequest(), rebuild_database_list(), RehashCatCache(), ReorderBufferAbortOld(), ReorderBufferBuildTupleCidHash(), ReorderBufferCleanupTXN(), ReorderBufferCopySnap(), ReorderBufferIterTXNFinish(), ReorderBufferIterTXNInit(), ReorderBufferIterTXNNext(), ReorderBufferLargestTopTXN(), ReorderBufferRestoreChanges(), ReorderBufferSerializeTXN(), ReorderBufferStreamTXN(), ReorderBufferToastReplace(), ReorderBufferToastReset(), ReorderBufferTruncateTXN(), reset_on_dsm_detach(), ResetCatalogCache(), ResetPlanCache(), SearchCatCacheInternal(), SearchCatCacheList(), SignalSomeChildren(), SlabReset(), SlabStats(), and SnapBuildDistributeNewCatalogSnapshot().

◆ dlist_foreach

#define dlist_foreach (   iter,
  lhead 
)
Value:
(iter).end = &(lhead)->head, \
(iter).cur = (iter).end->next ? (iter).end->next : (iter).end; \
(iter).cur != (iter).end; \
(iter).cur = (iter).cur->next)
struct cursor * next
Definition: type.h:141
struct cursor * cur
Definition: ecpg.c:28
#define AssertVariableIsOfTypeMacro(varname, typename)
Definition: c.h:966

Definition at line 526 of file ilist.h.

Referenced by addItemsToLeaf(), AssertChangeLsnOrder(), AssertTXNLsnOrder(), autovac_balance_cost(), computeLeafRecompressWALData(), CountChildren(), dataPlaceToPageLeafRecompress(), do_autovacuum(), dsm_attach(), dsm_find_mapping(), FindLockCycleRecurse(), GenerationStats(), GetBlockerStatusData(), ginVacuumPostingTreeLeaf(), HandleParallelMessages(), launch_worker(), leafRepackItems(), mXactCacheGetById(), mXactCacheGetBySet(), PlanCacheObjectCallback(), PlanCacheRelCallback(), PostmasterMarkPIDForWorkerNotify(), processCancelRequest(), rebuild_database_list(), ReorderBufferBuildTupleCidHash(), ReorderBufferCopySnap(), ReorderBufferIterTXNInit(), ReorderBufferLargestTopTXN(), ReorderBufferSerializeTXN(), ReorderBufferStreamTXN(), ReorderBufferToastReplace(), reset_on_dsm_detach(), ResetPlanCache(), SearchCatCacheInternal(), SearchCatCacheList(), SignalSomeChildren(), SlabStats(), and SnapBuildDistributeNewCatalogSnapshot().

◆ dlist_foreach_modify

#define dlist_foreach_modify (   iter,
  lhead 
)
Value:
(iter).end = &(lhead)->head, \
(iter).cur = (iter).end->next ? (iter).end->next : (iter).end, \
(iter).next = (iter).cur->next; \
(iter).cur != (iter).end; \
(iter).cur = (iter).next, (iter).next = (iter).cur->next)
struct cursor * next
Definition: type.h:141
struct cursor * cur
Definition: ecpg.c:28
#define AssertVariableIsOfTypeMacro(varname, typename)
Definition: c.h:966

Definition at line 543 of file ilist.h.

Referenced by AtEOXact_SMgr(), cache_reduce_memory(), CatCacheInvalidate(), CleanupBackend(), GenerationReset(), get_flush_position(), HandleChildCrash(), InvalidateConstraintCacheCallBack(), logical_heap_rewrite_flush_mappings(), RehashCatCache(), ReorderBufferAbortOld(), ReorderBufferCleanupTXN(), ReorderBufferRestoreChanges(), ReorderBufferSerializeTXN(), ReorderBufferToastReset(), ReorderBufferTruncateTXN(), ResetCatalogCache(), and SlabReset().

◆ dlist_head_element

#define dlist_head_element (   type,
  membername,
  lhead 
)
Value:
(AssertVariableIsOfTypeMacro(((type *) NULL)->membername, dlist_node), \
(type *) dlist_head_element_off(lhead, offsetof(type, membername)))
#define AssertVariableIsOfTypeMacro(varname, typename)
Definition: c.h:966
static void * dlist_head_element_off(dlist_head *head, size_t off)
Definition: ilist.h:458
#define offsetof(type, field)
Definition: c.h:727

Definition at line 506 of file ilist.h.

Referenced by AtEOSubXact_Parallel(), AtEOXact_Parallel(), dsm_backend_shutdown(), dsm_detach_all(), ReorderBufferGetOldestTXN(), ReorderBufferGetOldestXmin(), ReorderBufferIterTXNInit(), ReorderBufferIterTXNNext(), and SlabAlloc().

◆ dlist_reverse_foreach

#define dlist_reverse_foreach (   iter,
  lhead 
)
Value:
(iter).end = &(lhead)->head, \
(iter).cur = (iter).end->prev ? (iter).end->prev : (iter).end; \
(iter).cur != (iter).end; \
(iter).cur = (iter).cur->prev)
struct cursor * cur
Definition: ecpg.c:28
#define AssertVariableIsOfTypeMacro(varname, typename)
Definition: c.h:966

Definition at line 557 of file ilist.h.

Referenced by do_start_worker().

◆ DLIST_STATIC_INIT

#define DLIST_STATIC_INIT (   name)    {{&(name).head, &(name).head}}

Definition at line 248 of file ilist.h.

◆ dlist_tail_element

#define dlist_tail_element (   type,
  membername,
  lhead 
)
Value:
(AssertVariableIsOfTypeMacro(((type *) NULL)->membername, dlist_node), \
((type *) dlist_tail_element_off(lhead, offsetof(type, membername))))
#define AssertVariableIsOfTypeMacro(varname, typename)
Definition: c.h:966
static void * dlist_tail_element_off(dlist_head *head, size_t off)
Definition: ilist.h:475
#define offsetof(type, field)
Definition: c.h:727

Definition at line 515 of file ilist.h.

Referenced by AutoVacLauncherMain(), get_flush_position(), and launcher_determine_sleep().

◆ slist_check

#define slist_check (   head)    ((void) (head))

◆ slist_container

◆ slist_foreach

#define slist_foreach (   iter,
  lhead 
)
Value:
(iter).cur = (lhead)->head.next; \
(iter).cur != NULL; \
(iter).cur = (iter).cur->next)
struct cursor * next
Definition: type.h:141
struct cursor * cur
Definition: ecpg.c:28
#define AssertVariableIsOfTypeMacro(varname, typename)
Definition: c.h:966

Definition at line 719 of file ilist.h.

Referenced by BackgroundWorkerShmemInit(), BackgroundWorkerStopNotifications(), CatalogCacheCompareTuple(), CatalogCacheFlushCatalog(), FindRegisteredWorkerBySlotNumber(), HandleChildCrash(), pg_event_trigger_dropped_objects(), PrepareToInvalidateCacheTuple(), and ResetCatalogCaches().

◆ slist_foreach_modify

#define slist_foreach_modify (   iter,
  lhead 
)
Value:
(iter).prev = &(lhead)->head, \
(iter).cur = (iter).prev->next, \
(iter).next = (iter).cur ? (iter).cur->next : NULL; \
(iter).cur != NULL; \
(iter).prev = (iter).cur, \
(iter).cur = (iter).next, \
(iter).next = (iter).next ? (iter).next->next : NULL)
struct cursor * next
Definition: type.h:141
struct cursor * cur
Definition: ecpg.c:28
#define AssertVariableIsOfTypeMacro(varname, typename)
Definition: c.h:966

Definition at line 735 of file ilist.h.

Referenced by AtEOSubXact_SPI(), cancel_on_dsm_detach(), CleanupBackgroundWorker(), DetermineSleepTime(), ForgetUnstartedBackgroundWorkers(), maybe_start_bgworkers(), ResetBackgroundWorkerCrashTimes(), and SPI_freetuptable().

◆ slist_head_element

#define slist_head_element (   type,
  membername,
  lhead 
)
Value:
(AssertVariableIsOfTypeMacro(((type *) NULL)->membername, slist_node), \
(type *) slist_head_element_off(lhead, offsetof(type, membername)))
#define AssertVariableIsOfTypeMacro(varname, typename)
Definition: c.h:966
static void * slist_head_element_off(slist_head *head, size_t off)
Definition: ilist.h:649
#define offsetof(type, field)
Definition: c.h:727

Definition at line 703 of file ilist.h.

◆ SLIST_STATIC_INIT

#define SLIST_STATIC_INIT (   name)    {{NULL}}

Definition at line 249 of file ilist.h.

Typedef Documentation

◆ dlist_head

typedef struct dlist_head dlist_head

◆ dlist_iter

typedef struct dlist_iter dlist_iter

◆ dlist_mutable_iter

◆ dlist_node

typedef struct dlist_node dlist_node

Definition at line 120 of file ilist.h.

◆ slist_head

typedef struct slist_head slist_head

◆ slist_iter

typedef struct slist_iter slist_iter

◆ slist_mutable_iter

◆ slist_node

typedef struct slist_node slist_node

Definition at line 190 of file ilist.h.

Function Documentation

◆ dlist_delete()

◆ dlist_has_next()

static bool dlist_has_next ( dlist_head head,
dlist_node node 
)
inlinestatic

Definition at line 421 of file ilist.h.

References dlist_head::head, and dlist_node::next.

Referenced by addItemsToLeaf(), dataPlaceToPageLeafSplit(), dlist_next_node(), leafRepackItems(), and ReorderBufferIterTXNNext().

422 {
423  return node->next != &head->head;
424 }
dlist_node * next
Definition: ilist.h:124
dlist_node head
Definition: ilist.h:144

◆ dlist_has_prev()

static bool dlist_has_prev ( dlist_head head,
dlist_node node 
)
inlinestatic

Definition at line 431 of file ilist.h.

References dlist_head::head, and dlist_node::prev.

Referenced by dataBeginPlaceToPageLeaf(), and dlist_prev_node().

432 {
433  return node->prev != &head->head;
434 }
dlist_node * prev
Definition: ilist.h:123
dlist_node head
Definition: ilist.h:144

◆ dlist_head_element_off()

static void* dlist_head_element_off ( dlist_head head,
size_t  off 
)
inlinestatic

Definition at line 458 of file ilist.h.

References Assert, dlist_is_empty(), dlist_head::head, and dlist_node::next.

Referenced by dlist_head_node().

459 {
460  Assert(!dlist_is_empty(head));
461  return (char *) head->head.next - off;
462 }
dlist_node * next
Definition: ilist.h:124
#define Assert(condition)
Definition: c.h:804
static bool dlist_is_empty(dlist_head *head)
Definition: ilist.h:289
dlist_node head
Definition: ilist.h:144

◆ dlist_head_node()

static dlist_node* dlist_head_node ( dlist_head head)
inlinestatic

Definition at line 468 of file ilist.h.

References dlist_head_element_off().

Referenced by dataPlaceToPageLeafSplit(), and leafRepackItems().

469 {
470  return (dlist_node *) dlist_head_element_off(head, 0);
471 }
static void * dlist_head_element_off(dlist_head *head, size_t off)
Definition: ilist.h:458

◆ dlist_init()

◆ dlist_insert_after()

static void dlist_insert_after ( dlist_node after,
dlist_node node 
)
inlinestatic

Definition at line 334 of file ilist.h.

References dlist_node::next, and dlist_node::prev.

Referenced by leafRepackItems().

335 {
336  node->prev = after;
337  node->next = after->next;
338  after->next = node;
339  node->next->prev = node;
340 }
dlist_node * next
Definition: ilist.h:124
dlist_node * prev
Definition: ilist.h:123

◆ dlist_insert_before()

static void dlist_insert_before ( dlist_node before,
dlist_node node 
)
inlinestatic

Definition at line 346 of file ilist.h.

References before(), dlist_node::next, and dlist_node::prev.

Referenced by ReorderBufferTransferSnapToParent().

347 {
348  node->prev = before->prev;
349  node->next = before;
350  before->prev = node;
351  node->prev->next = node;
352 }
dlist_node * next
Definition: ilist.h:124
static int before(chr x, chr y)
Definition: regc_locale.c:492
dlist_node * prev
Definition: ilist.h:123

◆ dlist_is_empty()

◆ dlist_move_head()

static void dlist_move_head ( dlist_head head,
dlist_node node 
)
inlinestatic

Definition at line 385 of file ilist.h.

References dlist_check, dlist_delete(), dlist_push_head(), dlist_head::head, and dlist_node::next.

Referenced by launch_worker(), mXactCacheGetById(), mXactCacheGetBySet(), SearchCatCacheInternal(), and SearchCatCacheList().

386 {
387  /* fast path if it's already at the head */
388  if (head->head.next == node)
389  return;
390 
391  dlist_delete(node);
392  dlist_push_head(head, node);
393 
394  dlist_check(head);
395 }
static void dlist_push_head(dlist_head *head, dlist_node *node)
Definition: ilist.h:300
dlist_node * next
Definition: ilist.h:124
static void dlist_delete(dlist_node *node)
Definition: ilist.h:358
#define dlist_check(head)
Definition: ilist.h:267
dlist_node head
Definition: ilist.h:144

◆ dlist_move_tail()

static void dlist_move_tail ( dlist_head head,
dlist_node node 
)
inlinestatic

Definition at line 404 of file ilist.h.

References dlist_check, dlist_delete(), dlist_push_tail(), dlist_head::head, and dlist_node::prev.

Referenced by cache_lookup().

405 {
406  /* fast path if it's already at the tail */
407  if (head->head.prev == node)
408  return;
409 
410  dlist_delete(node);
411  dlist_push_tail(head, node);
412 
413  dlist_check(head);
414 }
static void dlist_push_tail(dlist_head *head, dlist_node *node)
Definition: ilist.h:317
static void dlist_delete(dlist_node *node)
Definition: ilist.h:358
dlist_node * prev
Definition: ilist.h:123
#define dlist_check(head)
Definition: ilist.h:267
dlist_node head
Definition: ilist.h:144

◆ dlist_next_node()

static dlist_node* dlist_next_node ( dlist_head head,
dlist_node node 
)
inlinestatic

Definition at line 440 of file ilist.h.

References Assert, dlist_has_next(), and dlist_node::next.

Referenced by addItemsToLeaf(), dataPlaceToPageLeafSplit(), leafRepackItems(), and ReorderBufferIterTXNNext().

441 {
442  Assert(dlist_has_next(head, node));
443  return node->next;
444 }
dlist_node * next
Definition: ilist.h:124
static bool dlist_has_next(dlist_head *head, dlist_node *node)
Definition: ilist.h:421
#define Assert(condition)
Definition: c.h:804

◆ dlist_pop_head_node()

static dlist_node* dlist_pop_head_node ( dlist_head head)
inlinestatic

Definition at line 368 of file ilist.h.

References Assert, dlist_delete(), dlist_is_empty(), dlist_head::head, and dlist_node::next.

Referenced by do_start_worker(), ReorderBufferIterTXNFinish(), and ReorderBufferIterTXNNext().

369 {
370  dlist_node *node;
371 
372  Assert(!dlist_is_empty(head));
373  node = head->head.next;
374  dlist_delete(node);
375  return node;
376 }
dlist_node * next
Definition: ilist.h:124
static void dlist_delete(dlist_node *node)
Definition: ilist.h:358
#define Assert(condition)
Definition: c.h:804
static bool dlist_is_empty(dlist_head *head)
Definition: ilist.h:289
dlist_node head
Definition: ilist.h:144

◆ dlist_prev_node()

static dlist_node* dlist_prev_node ( dlist_head head,
dlist_node node 
)
inlinestatic

Definition at line 450 of file ilist.h.

References Assert, dlist_has_prev(), and dlist_node::prev.

Referenced by dataBeginPlaceToPageLeaf(), and leafRepackItems().

451 {
452  Assert(dlist_has_prev(head, node));
453  return node->prev;
454 }
#define Assert(condition)
Definition: c.h:804
dlist_node * prev
Definition: ilist.h:123
static bool dlist_has_prev(dlist_head *head, dlist_node *node)
Definition: ilist.h:431

◆ dlist_push_head()

static void dlist_push_head ( dlist_head head,
dlist_node node 
)
inlinestatic

Definition at line 300 of file ilist.h.

References dlist_check, dlist_init(), dlist_head::head, dlist_node::next, and dlist_node::prev.

Referenced by AutoVacLauncherMain(), AutoVacuumShmemInit(), AutoVacWorkerMain(), BackendStartup(), BecomeLockGroupLeader(), CatalogCacheCreateEntry(), CreateParallelContext(), dlist_move_head(), do_start_bgworker(), dsm_create_descriptor(), FreeWorkerInfo(), GenerationAlloc(), mXactCachePut(), rebuild_database_list(), RehashCatCache(), SearchCatCacheList(), SlabAlloc(), SlabFree(), and StartAutovacuumWorker().

301 {
302  if (head->head.next == NULL) /* convert NULL header to circular */
303  dlist_init(head);
304 
305  node->next = head->head.next;
306  node->prev = &head->head;
307  node->next->prev = node;
308  head->head.next = node;
309 
310  dlist_check(head);
311 }
dlist_node * next
Definition: ilist.h:124
static void dlist_init(dlist_head *head)
Definition: ilist.h:278
dlist_node * prev
Definition: ilist.h:123
#define dlist_check(head)
Definition: ilist.h:267
dlist_node head
Definition: ilist.h:144

◆ dlist_push_tail()

static void dlist_push_tail ( dlist_head head,
dlist_node node 
)
inlinestatic

Definition at line 317 of file ilist.h.

References dlist_check, dlist_init(), dlist_head::head, dlist_node::next, and dlist_node::prev.

Referenced by addItemsToLeaf(), BecomeLockGroupMember(), cache_lookup(), disassembleLeaf(), dlist_move_tail(), GetCachedExpression(), logical_rewrite_log_mapping(), ReorderBufferAddNewTupleCids(), ReorderBufferAssignChild(), ReorderBufferIterTXNNext(), ReorderBufferQueueChange(), ReorderBufferRestoreChange(), ReorderBufferSetBaseSnapshot(), ReorderBufferToastAppendChunk(), ReorderBufferTXNByXid(), ri_LoadConstraintInfo(), SaveCachedPlan(), smgrclearowner(), smgropen(), and store_flush_position().

318 {
319  if (head->head.next == NULL) /* convert NULL header to circular */
320  dlist_init(head);
321 
322  node->next = &head->head;
323  node->prev = head->head.prev;
324  node->prev->next = node;
325  head->head.prev = node;
326 
327  dlist_check(head);
328 }
dlist_node * next
Definition: ilist.h:124
static void dlist_init(dlist_head *head)
Definition: ilist.h:278
dlist_node * prev
Definition: ilist.h:123
#define dlist_check(head)
Definition: ilist.h:267
dlist_node head
Definition: ilist.h:144

◆ dlist_tail_element_off()

static void* dlist_tail_element_off ( dlist_head head,
size_t  off 
)
inlinestatic

Definition at line 475 of file ilist.h.

References Assert, dlist_is_empty(), dlist_head::head, and dlist_node::prev.

Referenced by dlist_tail_node().

476 {
477  Assert(!dlist_is_empty(head));
478  return (char *) head->head.prev - off;
479 }
#define Assert(condition)
Definition: c.h:804
dlist_node * prev
Definition: ilist.h:123
static bool dlist_is_empty(dlist_head *head)
Definition: ilist.h:289
dlist_node head
Definition: ilist.h:144

◆ dlist_tail_node()

static dlist_node* dlist_tail_node ( dlist_head head)
inlinestatic

Definition at line 485 of file ilist.h.

References dlist_tail_element_off().

Referenced by dataBeginPlaceToPageLeaf(), and mXactCachePut().

486 {
487  return (dlist_node *) dlist_tail_element_off(head, 0);
488 }
static void * dlist_tail_element_off(dlist_head *head, size_t off)
Definition: ilist.h:475

◆ slist_delete()

void slist_delete ( slist_head head,
slist_node node 
)

Definition at line 31 of file ilist.c.

References Assert, cur, dlist_check, elog, ERROR, dlist_head::head, slist_head::head, dlist_node::next, slist_node::next, PG_USED_FOR_ASSERTS_ONLY, dlist_node::prev, and slist_check.

32 {
33  slist_node *last = &head->head;
34  slist_node *cur;
35  bool found PG_USED_FOR_ASSERTS_ONLY = false;
36 
37  while ((cur = last->next) != NULL)
38  {
39  if (cur == node)
40  {
41  last->next = cur->next;
42 #ifdef USE_ASSERT_CHECKING
43  found = true;
44 #endif
45  break;
46  }
47  last = cur;
48  }
49  Assert(found);
50 
51  slist_check(head);
52 }
slist_node head
Definition: ilist.h:205
struct cursor * cur
Definition: ecpg.c:28
#define slist_check(head)
Definition: ilist.h:268
slist_node * next
Definition: ilist.h:193
#define Assert(condition)
Definition: c.h:804
#define PG_USED_FOR_ASSERTS_ONLY
Definition: c.h:155

◆ slist_delete_current()

static void slist_delete_current ( slist_mutable_iter iter)
inlinestatic

Definition at line 671 of file ilist.h.

References slist_mutable_iter::cur, slist_node::next, slist_mutable_iter::next, and slist_mutable_iter::prev.

Referenced by AtEOSubXact_SPI(), cancel_on_dsm_detach(), ForgetBackgroundWorker(), and SPI_freetuptable().

672 {
673  /*
674  * Update previous element's forward link. If the iteration is at the
675  * first list element, iter->prev will point to the list header's "head"
676  * field, so we don't need a special case for that.
677  */
678  iter->prev->next = iter->next;
679 
680  /*
681  * Reset cur to prev, so that prev will continue to point to the prior
682  * valid list element after slist_foreach_modify() advances to the next.
683  */
684  iter->cur = iter->prev;
685 }
slist_node * next
Definition: ilist.h:242
slist_node * cur
Definition: ilist.h:241
slist_node * next
Definition: ilist.h:193
slist_node * prev
Definition: ilist.h:243

◆ slist_has_next()

static bool slist_has_next ( slist_head head,
slist_node node 
)
inlinestatic

Definition at line 630 of file ilist.h.

References slist_node::next, and slist_check.

Referenced by slist_next_node().

631 {
632  slist_check(head);
633 
634  return node->next != NULL;
635 }
#define slist_check(head)
Definition: ilist.h:268
slist_node * next
Definition: ilist.h:193

◆ slist_head_element_off()

static void* slist_head_element_off ( slist_head head,
size_t  off 
)
inlinestatic

Definition at line 649 of file ilist.h.

References Assert, slist_head::head, slist_node::next, and slist_is_empty().

Referenced by slist_head_node().

650 {
651  Assert(!slist_is_empty(head));
652  return (char *) head->head.next - off;
653 }
slist_node head
Definition: ilist.h:205
static bool slist_is_empty(slist_head *head)
Definition: ilist.h:582
slist_node * next
Definition: ilist.h:193
#define Assert(condition)
Definition: c.h:804

◆ slist_head_node()

static slist_node* slist_head_node ( slist_head head)
inlinestatic

Definition at line 659 of file ilist.h.

References slist_head_element_off().

660 {
661  return (slist_node *) slist_head_element_off(head, 0);
662 }
static void * slist_head_element_off(slist_head *head, size_t off)
Definition: ilist.h:649

◆ slist_init()

static void slist_init ( slist_head head)
inlinestatic

Definition at line 573 of file ilist.h.

References slist_head::head, and slist_node::next.

Referenced by dsm_create_descriptor(), EventTriggerBeginCompleteQuery(), InitCatCache(), and SPI_connect_ext().

574 {
575  head->head.next = NULL;
576 }
slist_node head
Definition: ilist.h:205
slist_node * next
Definition: ilist.h:193

◆ slist_insert_after()

static void slist_insert_after ( slist_node after,
slist_node node 
)
inlinestatic

Definition at line 605 of file ilist.h.

References slist_node::next.

606 {
607  node->next = after->next;
608  after->next = node;
609 }
slist_node * next
Definition: ilist.h:193

◆ slist_is_empty()

static bool slist_is_empty ( slist_head head)
inlinestatic

Definition at line 582 of file ilist.h.

References slist_head::head, slist_node::next, and slist_check.

Referenced by dsm_detach(), EventTriggerSQLDrop(), reset_on_dsm_detach(), slist_head_element_off(), and slist_pop_head_node().

583 {
584  slist_check(head);
585 
586  return head->head.next == NULL;
587 }
slist_node head
Definition: ilist.h:205
#define slist_check(head)
Definition: ilist.h:268
slist_node * next
Definition: ilist.h:193

◆ slist_next_node()

static slist_node* slist_next_node ( slist_head head,
slist_node node 
)
inlinestatic

Definition at line 641 of file ilist.h.

References Assert, slist_node::next, and slist_has_next().

642 {
643  Assert(slist_has_next(head, node));
644  return node->next;
645 }
static bool slist_has_next(slist_head *head, slist_node *node)
Definition: ilist.h:630
slist_node * next
Definition: ilist.h:193
#define Assert(condition)
Definition: c.h:804

◆ slist_pop_head_node()

static slist_node* slist_pop_head_node ( slist_head head)
inlinestatic

Definition at line 615 of file ilist.h.

References Assert, slist_head::head, slist_node::next, slist_check, and slist_is_empty().

Referenced by dsm_detach(), and reset_on_dsm_detach().

616 {
617  slist_node *node;
618 
619  Assert(!slist_is_empty(head));
620  node = head->head.next;
621  head->head.next = node->next;
622  slist_check(head);
623  return node;
624 }
slist_node head
Definition: ilist.h:205
static bool slist_is_empty(slist_head *head)
Definition: ilist.h:582
#define slist_check(head)
Definition: ilist.h:268
slist_node * next
Definition: ilist.h:193
#define Assert(condition)
Definition: c.h:804

◆ slist_push_head()

static void slist_push_head ( slist_head head,
slist_node node 
)
inlinestatic

Definition at line 593 of file ilist.h.

References slist_head::head, slist_node::next, and slist_check.

Referenced by BackgroundWorkerStateChange(), EventTriggerSQLDropAddObject(), InitCatCache(), on_dsm_detach(), RegisterBackgroundWorker(), and spi_dest_startup().

594 {
595  node->next = head->head.next;
596  head->head.next = node;
597 
598  slist_check(head);
599 }
slist_node head
Definition: ilist.h:205
#define slist_check(head)
Definition: ilist.h:268
slist_node * next
Definition: ilist.h:193