pdf-devel
[Top][All Lists]
Advanced

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

Re: [pdf-devel] pdf_date.c, DATE_EXTRACT_INT


From: Juan Pedro Bolivar Puente
Subject: Re: [pdf-devel] pdf_date.c, DATE_EXTRACT_INT
Date: Tue, 20 Nov 2007 00:05:29 +0100

Hi,

My personal opinion is that it would be better to declare such a
function as a inline function. In old compilers it won't be inlined but
anyway you are calling malloc inside of it, which is proportionally
much slower than the function-call overhead; and most people use inline
compatible compilers :)


PS: Sorry for not contributing with GNU Pdf lately (I'm quite busy with
this right now: http://psychosynth.wordpress.com) but I'm still
following the development progress in the list and will gladly
contribute again in the future.



On Mon, 19 Nov 2007 22:13:26 +0100
Hardy Falk <address@hidden> wrote:

> Hi jemarch,
> The macro  DATE_EXTRACT_INT( NUM_DIGITS) is still buggy:
> > #define DATE_EXTRACT_INT(NUM_DIGITS,VAR)                 \
> >   do                                                     \
> >     {                                                    \
> >       aux_str = (char *) xmalloc (NUM_DIGITS);           \
> >       strncpy (aux_str, (string + pos), NUM_DIGITS);     \
> >       aux_str[NUM_DIGITS] = '\0'; \
> The allocated area is too small !
> >       if (pdf_str2int (aux_str, VAR) == PDF_ERROR)       \
> >         {                                                \
> >           goto error;                                    \
> >         }                                                \
> >       pos = pos + NUM_DIGITS;                            \
> >       free (aux_str);                                    \
> >     }                                                    \
> >   while (0)
> Additionally, there is a memory leak in the error branch.
> Can we use alloca() or even strdupa()?
> Why is aux_str declared in the enclosing scope? 
> 
> 
> 
> 
> 
> 




reply via email to

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