[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
malloc vs xmalloc in pk_str_replace
From: |
Bruno Haible |
Subject: |
malloc vs xmalloc in pk_str_replace |
Date: |
Sat, 11 Apr 2020 12:22:34 +0200 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-174-generic; KDE/5.18.0; x86_64; ; ) |
Hi,
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?
The obvious fix I propose is:
2020-04-11 Bruno Haible <address@hidden>
Use xmalloc, not malloc.
* lib/pk-utils.c (pk_str_replace): Use xmalloc, not malloc. Don't return
NULL.
0001-Use-xmalloc-not-malloc.patch
Description: Text Data
- malloc vs xmalloc in pk_str_replace,
Bruno Haible <=