Re: [PATCH 2/2] Use const more often

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Apr 17, 2012 at 3:28 AM, Keith Packard <keithp@xxxxxxxxxx> wrote:
> diff --git a/fc-lang/fc-lang.c b/fc-lang/fc-lang.c
> index 51717f9..d29dc10 100644
> --- a/fc-lang/fc-lang.c
> +++ b/fc-lang/fc-lang.c
> @@ -136,7 +136,7 @@ static FcCharSet *
>  scan (FILE *f, char *file, FcCharSetFreezer *freezer)
>  {
>     FcCharSet      *c = 0;
> -    FcCharSet      *n;
> +    const FcCharSet *n;
>     FcBool         del;
>     int                    start, end, ucs4;
>     char           buf[1024];
> @@ -164,7 +164,7 @@ scan (FILE *f, char *file, FcCharSetFreezer *freezer)
>                c = FcCharSetCreate ();
>            if (!FcCharSetMerge (c, n, NULL))
>                fatal (file, lineno, "out of memory");
> -           FcCharSetDestroy (n);
> +           FcCharSetDestroy ((FcCharSet *) n);
>            continue;
>        }
>        del = FcFalse;

Ah, this is tricky.. I guess that may be better add a comment "n" is
FC_REF_CONSTANT? also we should add "const" to the return value of
FcCharSetFreezeBase() too.

> diff --git a/src/fccache.c b/src/fccache.c
> index a72dbb6..5ed7edf 100644
> --- a/src/fccache.c
> +++ b/src/fccache.c
> @@ -1000,7 +1000,7 @@ FcDirCacheWrite (FcCache *cache, FcConfig *config)
>      */
>     if (cache->size < FC_CACHE_MIN_MMAP &&
>        (skip = FcCacheFindByAddr (cache)) &&
> -       FcStat (cache_hashed, &cache_stat))
> +       FcStat ((const char *) cache_hashed, &cache_stat))

We don't need this one anymore. FcStat() takes const FcChar8 * now by 647569d0.

> @@ -913,7 +913,7 @@ FcConfigEvaluate (FcPattern *p, FcExpr *e)
>        v = FcValueSave (v);
>        break;
>     case FcOpConst:
> -       if (FcNameConstant (e->u.constant, &v.u.i))
> +       if (FcNameConstant ((FcChar8 *) e->u.constant, &v.u.i))
>            v.type = FcTypeInteger;
>        else
>            v.type = FcTypeVoid;

This one too by 123d344f

> diff --git a/src/fcint.h b/src/fcint.h
> index 8179195..fd327de 100644
> --- a/src/fcint.h
> +++ b/src/fcint.h
> @@ -237,17 +237,17 @@ typedef enum _FcOp {
>  typedef struct _FcExpr {
>     FcOp   op;
>     union {
> -       int         ival;
> -       double      dval;
> -       const FcChar8       *sval;
> -       FcMatrix    *mval;
> -       FcBool      bval;
> -       FcCharSet   *cval;
> -       FcLangSet   *lval;
> -       FcObject    object;
> -       const FcChar8       *constant;
> +       int             ival;
> +       double          dval;
> +       const FcChar8   *sval;
> +       const FcMatrix  *mval;
> +       FcBool          bval;
> +       const FcCharSet *cval;
> +       FcLangSet       *lval;
> +       FcObject        object;
> +       const FcChar8   *constant;
>        struct {
> -           struct _FcExpr *left, *right;
> +           const struct _FcExpr *left, *right;
>        } tree;
>     } u;
>  } FcExpr;

I'm not sure what this change tries to address. FcMatrix is created by
FcExprCreateMatrix() only here and it's surely allocated by malloc()
in FcMatrixCopy(). also FcCharSet is came from FcParseCharSet() and
FcCharSetCreate(). I don't see any reason why you add a const there.

> @@ -261,7 +261,7 @@ FcExprDestroy (FcExpr *e)
>        break;
>     }
>
> -    e->op = FcOpNil;
> +    ((FcExpr *) e)->op = FcOpNil;
>  }
>
>  void

just wonder what we get better with this dirty hack... ?

-- 
Akira TAGOH
_______________________________________________
Fontconfig mailing list
Fontconfig@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/fontconfig



[Index of Archives]     [Fedora Fonts]     [Fedora Users]     [Fedora Cloud]     [Kernel]     [Fedora Packaging]     [Fedora Desktop]     [PAM]     [Gimp Graphics Editor]     [Yosemite News]

  Powered by Linux