poke-devel
[Top][All Lists]
Advanced

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

Re: malloc vs xmalloc in pk_str_replace


From: Jose E. Marchesi
Subject: Re: malloc vs xmalloc in pk_str_replace
Date: Sat, 11 Apr 2020 13:49:45 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Hi Bruno.
    
    In a current build, I get the warnings:
    
    pk-utils.c:184:13: warning: implicit declaration of function 'malloc' 
[-Wimplicit-function-declaration]
    pk-utils.c:184:13: warning: incompatible implicit declaration of built-in 
function 'malloc'
    
    This is caused by use of malloc() without '#include <stdlib.h> in this file.
    
    But why use malloc() at all, when
      - other functions in the same file use xmalloc() already,
      - the caller in pkl.c does not check for a NULL result, i.e. would
        crash if the function returned NULL?

We recently moved a lot of code to a library libpoke.so, with sources in
lib/.

But that was just the first step.

Now we will be reworking every place in the library code that may abort
or exit, and that includes replacing xmallocs with mallocs and adjust
the corresponding APIs in order to report the errors to the libpoke
client.

I just pushed a patch that includes stdlib in pk-utils.c
Thanks for noticing! :)



reply via email to

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