LCOV - differential code coverage report
Current view: top level - src/fe_utils - simple_list.c (source / functions) Coverage Total Hit UBC GNC CBC DCB
Current: 0e5ff9b9b45a657aea12440478dc002e9b01f138 vs 0123ce131fca454009439dfa3b2266d1d40737d7 Lines: 92.3 % 65 60 5 2 58 2
Current Date: 2026-03-14 14:10:32 -0400 Functions: 88.9 % 9 8 1 2 6
Baseline: lcov-20260315-024220-baseline Branches: 83.3 % 24 20 4 20
Baseline Date: 2026-03-14 15:27:56 +0100 Line coverage date bins:
Legend: Lines:     hit not hit
Branches: + taken - not taken # not executed
(7,30] days: 100.0 % 2 2 2
(360..) days: 92.1 % 63 58 5 58
Function coverage date bins:
(360..) days: 88.9 % 9 8 1 2 6
Branch coverage date bins:
(360..) days: 83.3 % 24 20 4 20

 Age         Owner                    Branch data    TLA  Line data    Source code
                                  1                 :                : /*-------------------------------------------------------------------------
                                  2                 :                :  *
                                  3                 :                :  * Simple list facilities for frontend code
                                  4                 :                :  *
                                  5                 :                :  * Data structures for simple lists of OIDs and strings.  The support for
                                  6                 :                :  * these is very primitive compared to the backend's List facilities, but
                                  7                 :                :  * it's all we need in, eg, pg_dump.
                                  8                 :                :  *
                                  9                 :                :  *
                                 10                 :                :  * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
                                 11                 :                :  * Portions Copyright (c) 1994, Regents of the University of California
                                 12                 :                :  *
                                 13                 :                :  * src/fe_utils/simple_list.c
                                 14                 :                :  *
                                 15                 :                :  *-------------------------------------------------------------------------
                                 16                 :                :  */
                                 17                 :                : #include "postgres_fe.h"
                                 18                 :                : 
                                 19                 :                : #include "fe_utils/simple_list.h"
                                 20                 :                : 
                                 21                 :                : 
                                 22                 :                : /*
                                 23                 :                :  * Append an OID to the list.
                                 24                 :                :  */
                                 25                 :                : void
 3643 tgl@sss.pgh.pa.us          26                 :CBC          70 : simple_oid_list_append(SimpleOidList *list, Oid val)
                                 27                 :                : {
                                 28                 :                :     SimpleOidListCell *cell;
                                 29                 :                : 
   19 michael@paquier.xyz        30                 :GNC          70 :     cell = pg_malloc_object(SimpleOidListCell);
 3643 tgl@sss.pgh.pa.us          31                 :CBC          70 :     cell->next = NULL;
                                 32                 :             70 :     cell->val = val;
                                 33                 :                : 
                                 34         [ +  + ]:             70 :     if (list->tail)
                                 35                 :             24 :         list->tail->next = cell;
                                 36                 :                :     else
                                 37                 :             46 :         list->head = cell;
                                 38                 :             70 :     list->tail = cell;
                                 39                 :             70 : }
                                 40                 :                : 
                                 41                 :                : /*
                                 42                 :                :  * Is OID present in the list?
                                 43                 :                :  */
                                 44                 :                : bool
                                 45                 :          51401 : simple_oid_list_member(SimpleOidList *list, Oid val)
                                 46                 :                : {
                                 47                 :                :     SimpleOidListCell *cell;
                                 48                 :                : 
                                 49         [ +  + ]:          59266 :     for (cell = list->head; cell; cell = cell->next)
                                 50                 :                :     {
                                 51         [ +  + ]:           7931 :         if (cell->val == val)
                                 52                 :             66 :             return true;
                                 53                 :                :     }
                                 54                 :          51335 :     return false;
                                 55                 :                : }
                                 56                 :                : 
                                 57                 :                : /*
                                 58                 :                :  * Append a string to the list.
                                 59                 :                :  *
                                 60                 :                :  * The given string is copied, so it need not survive past the call.
                                 61                 :                :  */
                                 62                 :                : void
                                 63                 :           6047 : simple_string_list_append(SimpleStringList *list, const char *val)
                                 64                 :                : {
                                 65                 :                :     SimpleStringListCell *cell;
                                 66                 :                : 
                                 67                 :                :     cell = (SimpleStringListCell *)
 3189                            68                 :           6047 :         pg_malloc(offsetof(SimpleStringListCell, val) + strlen(val) + 1);
                                 69                 :                : 
 3643                            70                 :           6047 :     cell->next = NULL;
                                 71                 :           6047 :     cell->touched = false;
                                 72                 :           6047 :     strcpy(cell->val, val);
                                 73                 :                : 
                                 74         [ +  + ]:           6047 :     if (list->tail)
                                 75                 :           5621 :         list->tail->next = cell;
                                 76                 :                :     else
                                 77                 :            426 :         list->head = cell;
                                 78                 :           6047 :     list->tail = cell;
                                 79                 :           6047 : }
                                 80                 :                : 
                                 81                 :                : /*
                                 82                 :                :  * Is string present in the list?
                                 83                 :                :  *
                                 84                 :                :  * If found, the "touched" field of the first match is set true.
                                 85                 :                :  */
                                 86                 :                : bool
                                 87                 :            236 : simple_string_list_member(SimpleStringList *list, const char *val)
                                 88                 :                : {
                                 89                 :                :     SimpleStringListCell *cell;
                                 90                 :                : 
                                 91         [ +  + ]:            332 :     for (cell = list->head; cell; cell = cell->next)
                                 92                 :                :     {
                                 93         [ +  + ]:            118 :         if (strcmp(cell->val, val) == 0)
                                 94                 :                :         {
                                 95                 :             22 :             cell->touched = true;
                                 96                 :             22 :             return true;
                                 97                 :                :         }
                                 98                 :                :     }
                                 99                 :            214 :     return false;
                                100                 :                : }
                                101                 :                : 
                                102                 :                : /*
                                103                 :                :  * Destroy an OID list
                                104                 :                :  */
                                105                 :                : void
 2420 michael@paquier.xyz       106                 :              1 : simple_oid_list_destroy(SimpleOidList *list)
                                107                 :                : {
                                108                 :                :     SimpleOidListCell *cell;
                                109                 :                : 
                                110                 :              1 :     cell = list->head;
                                111         [ +  + ]:              5 :     while (cell != NULL)
                                112                 :                :     {
                                113                 :                :         SimpleOidListCell *next;
                                114                 :                : 
                                115                 :              4 :         next = cell->next;
                                116                 :              4 :         pg_free(cell);
                                117                 :              4 :         cell = next;
                                118                 :                :     }
                                119                 :              1 : }
                                120                 :                : 
                                121                 :                : /*
                                122                 :                :  * Destroy a string list
                                123                 :                :  */
                                124                 :                : void
                                125                 :            138 : simple_string_list_destroy(SimpleStringList *list)
                                126                 :                : {
                                127                 :                :     SimpleStringListCell *cell;
                                128                 :                : 
                                129                 :            138 :     cell = list->head;
                                130         [ +  + ]:           5328 :     while (cell != NULL)
                                131                 :                :     {
                                132                 :                :         SimpleStringListCell *next;
                                133                 :                : 
                                134                 :           5190 :         next = cell->next;
                                135                 :           5190 :         pg_free(cell);
                                136                 :           5190 :         cell = next;
                                137                 :                :     }
                                138                 :            138 : }
                                139                 :                : 
                                140                 :                : /*
                                141                 :                :  * Find first not-touched list entry, if there is one.
                                142                 :                :  */
                                143                 :                : const char *
 3643 tgl@sss.pgh.pa.us         144                 :UBC           0 : simple_string_list_not_touched(SimpleStringList *list)
                                145                 :                : {
                                146                 :                :     SimpleStringListCell *cell;
                                147                 :                : 
                                148         [ #  # ]:              0 :     for (cell = list->head; cell; cell = cell->next)
                                149                 :                :     {
                                150         [ #  # ]:              0 :         if (!cell->touched)
                                151                 :              0 :             return cell->val;
                                152                 :                :     }
                                153                 :              0 :     return NULL;
                                154                 :                : }
                                155                 :                : 
                                156                 :                : /*
                                157                 :                :  * Append a pointer to the list.
                                158                 :                :  *
                                159                 :                :  * Caller must ensure that the pointer remains valid.
                                160                 :                :  */
                                161                 :                : void
 2341 alvherre@alvh.no-ip.      162                 :CBC        8715 : simple_ptr_list_append(SimplePtrList *list, void *ptr)
                                163                 :                : {
                                164                 :                :     SimplePtrListCell *cell;
                                165                 :                : 
   19 michael@paquier.xyz       166                 :GNC        8715 :     cell = pg_malloc_object(SimplePtrListCell);
 2341 alvherre@alvh.no-ip.      167                 :CBC        8715 :     cell->next = NULL;
                                168                 :           8715 :     cell->ptr = ptr;
                                169                 :                : 
                                170         [ +  + ]:           8715 :     if (list->tail)
                                171                 :           8266 :         list->tail->next = cell;
                                172                 :                :     else
                                173                 :            449 :         list->head = cell;
                                174                 :           8715 :     list->tail = cell;
                                175                 :           8715 : }
                                176                 :                : 
                                177                 :                : /*
                                178                 :                :  * Destroy only pointer list and not the pointed-to element
                                179                 :                :  */
                                180                 :                : void
  534 rhaas@postgresql.org      181                 :             37 : simple_ptr_list_destroy(SimplePtrList *list)
                                182                 :                : {
                                183                 :                :     SimplePtrListCell *cell;
                                184                 :                : 
                                185                 :             37 :     cell = list->head;
                                186         [ +  + ]:            153 :     while (cell != NULL)
                                187                 :                :     {
                                188                 :                :         SimplePtrListCell *next;
                                189                 :                : 
                                190                 :            116 :         next = cell->next;
                                191                 :            116 :         pg_free(cell);
                                192                 :            116 :         cell = next;
                                193                 :                :     }
                                194                 :             37 : }
        

Generated by: LCOV version 2.4-beta