freetype-devel
[Top][All Lists]
Advanced

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

[ft-devel] why zcalloc() and zcfree() are written in zutil.c & ftgzip.c?


From: mpsuzuki
Subject: [ft-devel] why zcalloc() and zcfree() are written in zutil.c & ftgzip.c?
Date: Mon, 2 Feb 2009 23:38:27 +0900

Hi,

During the development for AtariST, I found that there
are 2 generic implementations of zcalloc() & zcfree() in
zutil.c and ftgzip.c.

Tracking the CVS history, originally zutil.c had the
implementations, and ftgzip.c didn't have. zutil.c had
3 implementations in it:
        A) Intel 8086, (MS-)DOS and Turbo-C implementation
        B) Intel 8086, (MS-)DOS and MS-C implementation
        C) generic implementation calling system calloc() & free()
The macro MY_ZALLOC was designed to enable C) when A) nor
B) is enabled. Thus, the conditional to enable A) or B)
does not check MY_ZCALLOC. All of them are derived from
original zlib.

On 2002-11-05, another implementation D) was introduced to
ftgzip.c.

        D) generic implementation calling FT_ALLOC() & FT_FREE()

At the same time, to avoid the conflict of C) & D),
ftgzip.c defines MY_ZCALLOC before the inclusion of
zutil.c. Differently from other modules, ftgzip.c
includes all files even in multi build, therefore,
now A), B) or D) can be enabled, but C) is never
enabled.

During the development for AtariST, I'm afraid that
the building on Intel 8086 with Turbo-C or MS-C fails,
by following scenario.

* The cpp conditionals in zutil.c to enable A) & B)
  does not check MY_ZCALLOC. Their design seems to
  assume that MY_ZCALLOC is undefined.

* Thus, on Intel 8086 with Turbo-C or MS-C, A) or B)
  is enabled, for first.

* Afterwards, on Intel 8086, ftgzip.c enables D) as
  far as the system has no existing zlib.

* As a result, there might be a conflict between A)
  and D), or, a conflict between B) and D).

So I have 2 questions:

Q1) the implementation C) in zutil.c is still required?
    I think following modification can solve bad scenario
    in above.

    F1) Remove the implementation C) from zutil.c.

    F2) Remove the definition of MY_ZCALLOC from ftgzip.c,
        or undefine it before the inclusion of zutils.
        Thus, zutil.c defines it when A) or B) is enabled.

    F3) If MY_ZALLOC is undefined and no system zlib, D) is
        enabled as fallback.

    Attached mps-ftgzip_pt1.c is a patch to apply this
    modification.

Q2) the comment in D) tells:

    /* it is better to use FreeType memory routines instead of raw
       'malloc/free' */

    It makes me think using A) or B) in FT2 is worse.
    I'm not sure if this is true on Intel 8086, but,
    I think there are 2 disadvantages to use A) & B).

    * Other modules in FT2 cannot use A) & B).
    * FT2 memory debugger cannot trace A) & B). 

    So, I think it is worthful to consider dropping
    A) & B) from zutil.c (and use D) always).

    Attached mps-ftgzip_pt2.c is a patch to do this,
    after mps-ftgzip_pt1.c.

I want to hear the comments, especially from FT2
developers on (MS-)DOS.

Regards,
mpsuzuki

Attachment: mps-ftgzip_pt1.diff
Description: Text Data

Attachment: mps-ftgzip_pt2.diff
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]