[poppler] strndup is not universally available

Jonathan Kew jonathan_kew at sil.org
Mon Jan 28 15:18:25 PST 2008

On 28 Jan 2008, at 10:45 pm, Kristian Høgsberg wrote:

> I see Albert already applied your patch, but this is really a pet
> peeve of mine.  DO NOT litter the code with #ifdef's like this and DO
> NOT leave open coded strndup implementations around the code base.  I
> mean, do you not see how unmanageble the code base becomes if future
> uses of strndup follow this pattern?

Sure, you're right. I was just trying to get the code to build, and  
touch it as little as possible in the process, but I'd be happy to  
see it handled better.

> The right fix is to split the
> code out into its own function and put it in goo/gmem.c along with the
> other memory/string functions there.

Sounds fine. Would you want that function to use the platform's  
strndup if available, or do you prefer to ignore it and use a local  
implementation in all cases?

I see there's copyString() in gmem.cc, which looks like a strdup  
reimplementation. The naming seems a bit illogical; why isn't it  
gstrdup? What should the version of strndup here be called, then?


More information about the poppler mailing list