freetype
[Top][All Lists]
Advanced

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

Re: [ft] rendering differences between 2.8 and 2.81


From: Werner LEMBERG
Subject: Re: [ft] rendering differences between 2.8 and 2.81
Date: Fri, 27 Oct 2017 08:30:49 +0200 (CEST)

> If my understanding is right, the fix is to prevent the memory
> returned from a ft_mem_realloc() gets zeroed twice when called with
> current count 0.

Yes.

> But the problem introduced is when new_count is less than cur_count
> (*See the break point below*), the memory is not zeroed even once.
> So uninitialized block of memory.  Please correct me if my
> observation is wrong.

Hmm.  A basic rule in FreeType's memory management is that a call to
FT_ALLOC *always* corresponds to C's `calloc' function, this is, it
always initializes the memory to zero.  FT_REALLOC, on the other side,
relies on the following C standard property (cited from the realloc
manpage as provided on GNU/Linux):

  The contents [of the memory block] will be unchanged in the range
  from the start of the region up to the minimum of the old and new
  sizes.

In other words, only if the reallocated buffer becomes *larger*,
FreeType has to initialize the new memory, and there is nothing to do
if the buffer becomes smaller.  This means that the case `new_count <
cur_count' doesn't need to be handled at all.

I don't see a bug in FreeType, but I might be wrong, of course :-)

Are you sure that your custom memory management follows the same
rules?


    Werner

reply via email to

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