RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  ____________________________________________________________________________

  Server: rpm5.org                         Name:   Jeff Johnson
  Root:   /v/rpm/cvs                       Email:  [EMAIL PROTECTED]
  Module: rpm                              Date:   20-Oct-2007 17:58:29
  Branch: HEAD                             Handle: 2007102016582801

  Modified files:
    rpm                     CHANGES
    rpm/rpmdb               header.c

  Log:
    - jbj: use tag data cache.

  Summary:
    Revision    Changes     Path
    1.1743      +1  -0      rpm/CHANGES
    1.103       +58 -40     rpm/rpmdb/header.c
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/CHANGES
  ============================================================================
  $ cvs diff -u -r1.1742 -r1.1743 CHANGES
  --- rpm/CHANGES       20 Oct 2007 15:37:39 -0000      1.1742
  +++ rpm/CHANGES       20 Oct 2007 15:58:28 -0000      1.1743
  @@ -1,4 +1,5 @@
   4.5 -> 5.0:
  +    - jbj: use tag data cache.
       - jbj: add tag data cache.
       - jbj: eliminate rpmec data type.
       - jbj: merge rpmec into HE_t.
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmdb/header.c
  ============================================================================
  $ cvs diff -u -r1.102 -r1.103 header.c
  --- rpm/rpmdb/header.c        20 Oct 2007 15:37:39 -0000      1.102
  +++ rpm/rpmdb/header.c        20 Oct 2007 15:58:29 -0000      1.103
  @@ -3456,6 +3456,53 @@
   }
   
   /**
  + * Create tag data cache.
  + * @param ntc                no. of elements
  + * @return           new tag data cache
  + */
  +static /[EMAIL PROTECTED]@*/ HE_t
  +rpmtcNew(int ntc)
  +     /[EMAIL PROTECTED]/
  +{
  +    HE_t ec = xcalloc(ntc+1, sizeof(*ec));
  +    return ec;
  +}
  +
  +/**
  + * Clean a tag container.
  + * @param he         tag container
  + */
  +static void rpmtcClean(/[EMAIL PROTECTED]@*/ HE_t he)
  +     /[EMAIL PROTECTED] he @*/
  +{
  +    if (he) {
  +     if (he->freeData)
  +         he->p.ptr = _free(he->p.ptr);
  +     memset(he, 0, sizeof(*he));
  +    }
  +    return;
  +}
  +
  +/**
  + * Destroy tag data cache.
  + * @param tc         tag data cache
  + * @param ntc                no. of elements
  + * @return           NULL always
  + */
  +static /[EMAIL PROTECTED]@*/ HE_t
  +rpmtcFree(/[EMAIL PROTECTED]@*/ HE_t tc, int ntc)
  +     /[EMAIL PROTECTED] ec @*/
  +{
  +    int i;
  +
  +    if (tc != NULL)
  +    for (i = 0; i < ntc; i++)
  +     rpmtcClean(tc + i);
  +    tc = _free(tc);
  +    return NULL;
  +}
  +
  +/**
    * Format a single item's value.
    * @param hsa                headerSprintf args
    * @param tag                tag
  @@ -3466,7 +3513,7 @@
   static char * formatValue(headerSprintfArgs hsa, sprintfTag tag, int element)
        /[EMAIL PROTECTED] hsa @*/
   {
  -    HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he));
  +    HE_t he = hsa->tc + hsa->i;
       char * val = NULL;
       size_t need = 0;
       char * t, * te;
  @@ -3476,6 +3523,8 @@
       HE_t vhe = memset(alloca(sizeof(*vhe)), 0, sizeof(*vhe));
       int_64 ival = 0;
   
  +    rpmtcClean(he);
  +
       if (tag->ext) {
        if (getExtension(hsa, tag->ext, &he->t, &he->p, &he->c, hsa->ec + 
tag->extNum))
        {
  @@ -3492,6 +3541,7 @@
            he->p.str = "(none)";
        }
   
  +#if  !defined(DYING) /* XXX notyet */
        /* XXX this test is unnecessary, array sizes are checked */
        switch (he->t) {
        default:
  @@ -3511,20 +3561,24 @@
            break;
        }
        he->freeData = 1;
  +#endif
       }
   
       if (tag->arrayCount) {
  +     countBuf = he->c;
  +#ifdef       DYING
   /[EMAIL PROTECTED] [EMAIL PROTECTED]/
        if (he->freeData) {
            he->p.ptr = headerFreeData(he->p.ptr, he->t);
            he->freeData = 0;
        }
   /[EMAIL PROTECTED] [EMAIL PROTECTED]/
  -
  -     countBuf = he->c;
  +#else
  +     rpmtcClean(he);
  +#endif
  +     he->t = RPM_INT32_TYPE;
        he->p.i32p = &countBuf;
        he->c = 1;
  -     he->t = RPM_INT32_TYPE;
       }
   
       if (he->p.ptr)
  @@ -3885,42 +3939,6 @@
       return NULL;
   }
   
  -/**
  - * Create tag data cache.
  - * @param ntc                no. of elements
  - * @return           new tag data cache
  - */
  -static /[EMAIL PROTECTED]@*/ HE_t
  -rpmtcNew(int ntc)
  -     /[EMAIL PROTECTED]/
  -{
  -    HE_t ec = xcalloc(ntc+1, sizeof(*ec));
  -    return ec;
  -}
  -
  -/**
  - * Destroy tag data cache.
  - * @param tc         tag data cache
  - * @param ntc                no. of elements
  - * @return           NULL always
  - */
  -static /[EMAIL PROTECTED]@*/ HE_t
  -rpmtcFree(/[EMAIL PROTECTED]@*/ HE_t tc, int ntc)
  -     /[EMAIL PROTECTED] ec @*/
  -{
  -    int i;
  -
  -    if (tc != NULL)
  -    for (i = 0; i < ntc; i++) {
  -     HE_t he = tc + i;
  -     if (he->freeData)
  -         he->p.ptr = _free(he->p.ptr);
  -     memset(tc, 0, sizeof(*tc));
  -    }
  -    tc = _free(tc);
  -    return NULL;
  -}
  -
   /** \ingroup header
    * Return formatted output string from header tags.
    * The returned string must be free()d.
  @@ .
______________________________________________________________________
RPM Package Manager                                    http://rpm5.org
CVS Sources Repository                                [email protected]

Reply via email to