LCOV - differential code coverage report
Current view: top level - src/fe_utils - simple_list.c (source / functions) Coverage Total Hit UBC CBC
Current: c70b6db34ffeab48beef1fb4ce61bcad3772b8dd vs 06473f5a344df8c9594ead90a609b86f6724cff8 Lines: 92.3 % 65 60 5 60
Current Date: 2025-09-06 07:49:51 +0900 Functions: 88.9 % 9 8 1 8
Baseline: lcov-20250906-005545-baseline Branches: 83.3 % 24 20 4 20
Baseline Date: 2025-09-05 08:21:35 +0100 Line coverage date bins:
Legend: Lines:     hit not hit
Branches: + taken - not taken # not executed
(30,360] days: 100.0 % 7 7 7
(360..) days: 91.4 % 58 53 5 53
Function coverage date bins:
(30,360] days: 100.0 % 1 1 1
(360..) days: 87.5 % 8 7 1 7
Branch coverage date bins:
(30,360] days: 100.0 % 2 2 2
(360..) days: 81.8 % 22 18 4 18

 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-2025, 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
 3453 tgl@sss.pgh.pa.us          26                 :CBC          70 : simple_oid_list_append(SimpleOidList *list, Oid val)
                                 27                 :                : {
                                 28                 :                :     SimpleOidListCell *cell;
                                 29                 :                : 
                                 30                 :             70 :     cell = (SimpleOidListCell *) pg_malloc(sizeof(SimpleOidListCell));
                                 31                 :             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                 :          39899 : simple_oid_list_member(SimpleOidList *list, Oid val)
                                 46                 :                : {
                                 47                 :                :     SimpleOidListCell *cell;
                                 48                 :                : 
                                 49         [ +  + ]:          47654 :     for (cell = list->head; cell; cell = cell->next)
                                 50                 :                :     {
                                 51         [ +  + ]:           7821 :         if (cell->val == val)
                                 52                 :             66 :             return true;
                                 53                 :                :     }
                                 54                 :          39833 :     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                 :           5757 : simple_string_list_append(SimpleStringList *list, const char *val)
                                 64                 :                : {
                                 65                 :                :     SimpleStringListCell *cell;
                                 66                 :                : 
                                 67                 :                :     cell = (SimpleStringListCell *)
 2999                            68                 :           5757 :         pg_malloc(offsetof(SimpleStringListCell, val) + strlen(val) + 1);
                                 69                 :                : 
 3453                            70                 :           5757 :     cell->next = NULL;
                                 71                 :           5757 :     cell->touched = false;
                                 72                 :           5757 :     strcpy(cell->val, val);
                                 73                 :                : 
                                 74         [ +  + ]:           5757 :     if (list->tail)
                                 75                 :           5341 :         list->tail->next = cell;
                                 76                 :                :     else
                                 77                 :            416 :         list->head = cell;
                                 78                 :           5757 :     list->tail = cell;
                                 79                 :           5757 : }
                                 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                 :            168 : simple_string_list_member(SimpleStringList *list, const char *val)
                                 88                 :                : {
                                 89                 :                :     SimpleStringListCell *cell;
                                 90                 :                : 
                                 91         [ +  + ]:            253 :     for (cell = list->head; cell; cell = cell->next)
                                 92                 :                :     {
                                 93         [ +  + ]:            106 :         if (strcmp(cell->val, val) == 0)
                                 94                 :                :         {
                                 95                 :             21 :             cell->touched = true;
                                 96                 :             21 :             return true;
                                 97                 :                :         }
                                 98                 :                :     }
                                 99                 :            147 :     return false;
                                100                 :                : }
                                101                 :                : 
                                102                 :                : /*
                                103                 :                :  * Destroy an OID list
                                104                 :                :  */
                                105                 :                : void
 2230 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                 :             25 : simple_string_list_destroy(SimpleStringList *list)
                                126                 :                : {
                                127                 :                :     SimpleStringListCell *cell;
                                128                 :                : 
                                129                 :             25 :     cell = list->head;
                                130         [ +  + ]:             61 :     while (cell != NULL)
                                131                 :                :     {
                                132                 :                :         SimpleStringListCell *next;
                                133                 :                : 
                                134                 :             36 :         next = cell->next;
                                135                 :             36 :         pg_free(cell);
                                136                 :             36 :         cell = next;
                                137                 :                :     }
                                138                 :             25 : }
                                139                 :                : 
                                140                 :                : /*
                                141                 :                :  * Find first not-touched list entry, if there is one.
                                142                 :                :  */
                                143                 :                : const char *
 3453 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
 2151 alvherre@alvh.no-ip.      162                 :CBC        8450 : simple_ptr_list_append(SimplePtrList *list, void *ptr)
                                163                 :                : {
                                164                 :                :     SimplePtrListCell *cell;
                                165                 :                : 
                                166                 :           8450 :     cell = (SimplePtrListCell *) pg_malloc(sizeof(SimplePtrListCell));
                                167                 :           8450 :     cell->next = NULL;
                                168                 :           8450 :     cell->ptr = ptr;
                                169                 :                : 
                                170         [ +  + ]:           8450 :     if (list->tail)
                                171                 :           8144 :         list->tail->next = cell;
                                172                 :                :     else
                                173                 :            306 :         list->head = cell;
                                174                 :           8450 :     list->tail = cell;
                                175                 :           8450 : }
                                176                 :                : 
                                177                 :                : /*
                                178                 :                :  * Destroy only pointer list and not the pointed-to element
                                179                 :                :  */
                                180                 :                : void
  344 rhaas@postgresql.org      181                 :             27 : simple_ptr_list_destroy(SimplePtrList *list)
                                182                 :                : {
                                183                 :                :     SimplePtrListCell *cell;
                                184                 :                : 
                                185                 :             27 :     cell = list->head;
                                186         [ +  + ]:             65 :     while (cell != NULL)
                                187                 :                :     {
                                188                 :                :         SimplePtrListCell *next;
                                189                 :                : 
                                190                 :             38 :         next = cell->next;
                                191                 :             38 :         pg_free(cell);
                                192                 :             38 :         cell = next;
                                193                 :                :     }
                                194                 :             27 : }
        

Generated by: LCOV version 2.4-beta