From 3040f895dbc9b6ff0fa9dbde20a51f92674e0f4a Mon Sep 17 00:00:00 2001 From: handa Date: Tue, 18 Oct 2005 01:24:51 +0000 Subject: [PATCH] (mplist__conc): Renamed from mplist_conc. Don't ref tail. (mplist_conc): Renamed to mplist__conc. (mplist__pop_unref): New function. --- src/plist.c | 74 +++++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 49 insertions(+), 25 deletions(-) diff --git a/src/plist.c b/src/plist.c index f96ab25..5769e63 100644 --- a/src/plist.c +++ b/src/plist.c @@ -816,6 +816,55 @@ mplist__serialize (MText *mt, MPlist *plist) return 0; } +/**en + @brief Concatenate two plists. + + The mplist__conc () function concatenates plist $TAIL at the end of + plist $PLIST and return $PLIST. If $TAIL is empty, return $PLIST + without modifying it. */ + +MPlist * +mplist__conc (MPlist *plist, MPlist *tail) +{ + MPlist *pl; + + if (MPLIST_TAIL_P (tail)) + return plist; + MPLIST_DO (pl, plist); + MPLIST_KEY (pl) = MPLIST_KEY (tail); + MPLIST_VAL (pl) = MPLIST_VAL (tail); + if (MPLIST_KEY (pl)->managing_key) + M17N_OBJECT_REF (MPLIST_VAL (pl)); + tail = MPLIST_NEXT (tail); + MPLIST_NEXT (pl) = tail; + M17N_OBJECT_REF (tail); + return plist; +} + +/*=*/ +/**en + @brief Discard a property at the beginning of a property list. + + The mplist__pop_unref () function removes a property at the + beginning of property list $PLIST, and if the property value is a + managed object, unref it. As a result, the second key and value + of the original $PLIST become the first of those of the new + $PLIST. */ + +void +mplist__pop_unref (MPlist *plist) +{ + MSymbol key; + void *val; + + if (MPLIST_TAIL_P (plist)) + return; + key = MPLIST_KEY (plist); + val = mplist_pop (plist); + if (key->managing_key) + M17N_OBJECT_UNREF (val); +} + /*** @} */ #endif /* !FOR_DOXYGEN || DOXYGEN_INTERNAL_MODULE */ @@ -1168,31 +1217,6 @@ mplist_pop (MPlist *plist) /*=*/ /***en - @brief Concatenate two plists. - - The mplist_conc () function concatenate plist $TAIL at the end of - plist $PLIST. - - @return If the operation was successful, this function return - $PLIST. Otherwise it returns @c NULL. */ - -MPlist * -mplist_conc (MPlist *plist, MPlist *tail) -{ - MPlist *pl; - - MPLIST_DO (pl, plist); - MPLIST_KEY (pl) = MPLIST_KEY (tail); - MPLIST_VAL (pl) = MPLIST_VAL (tail); - MPLIST_NEXT (pl) = MPLIST_NEXT (tail); - M17N_OBJECT_REF (tail); - - return plist; -} - - -/*=*/ -/***en @brief Find a property of a specific key in a property list. The mplist_find_by_key () function searches property list -- 1.7.10.4