misc-utils: use new xmalloc() wrapper
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
This commit is contained in:
parent
d7df7ba264
commit
87f3feac71
|
@ -19,6 +19,7 @@
|
||||||
* Arkadiusz Mikiewicz (1999-02-22)
|
* Arkadiusz Mikiewicz (1999-02-22)
|
||||||
* Li Zefan (2007-09-10).
|
* Li Zefan (2007-09-10).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
|
@ -34,6 +35,7 @@
|
||||||
#include <grp.h>
|
#include <grp.h>
|
||||||
|
|
||||||
#include "c.h"
|
#include "c.h"
|
||||||
|
#include "xalloc.h"
|
||||||
#include "nls.h"
|
#include "nls.h"
|
||||||
#include "widechar.h"
|
#include "widechar.h"
|
||||||
|
|
||||||
|
@ -194,9 +196,7 @@ readlink_to_namei(struct namei *nm, const char *path)
|
||||||
if (nm->relstart)
|
if (nm->relstart)
|
||||||
sz += nm->relstart + 1;
|
sz += nm->relstart + 1;
|
||||||
}
|
}
|
||||||
nm->abslink = malloc(sz + 1);
|
nm->abslink = xmalloc(sz + 1);
|
||||||
if (!nm->abslink)
|
|
||||||
err(EXIT_FAILURE, _("out of memory?"));
|
|
||||||
|
|
||||||
if (*sym != '/' && nm->relstart) {
|
if (*sym != '/' && nm->relstart) {
|
||||||
/* create the absolute path from the relative symlink */
|
/* create the absolute path from the relative symlink */
|
||||||
|
|
|
@ -17,7 +17,9 @@ for i in $@; do N=`echo "$i" | sed "s/$FROM/$TO/g"`; mv "$i" "$N"; done
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include "nls.h"
|
#include "nls.h"
|
||||||
|
#include "xalloc.h"
|
||||||
|
|
||||||
static char *progname;
|
static char *progname;
|
||||||
|
|
||||||
|
@ -33,11 +35,7 @@ do_rename(char *from, char *to, char *s) {
|
||||||
flen = strlen(from);
|
flen = strlen(from);
|
||||||
tlen = strlen(to);
|
tlen = strlen(to);
|
||||||
slen = strlen(s);
|
slen = strlen(s);
|
||||||
newname = malloc(tlen+slen+1);
|
newname = xmalloc(tlen+slen+1);
|
||||||
if (newname == NULL) {
|
|
||||||
fprintf(stderr, _("%s: out of memory\n"), progname);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
p = s;
|
p = s;
|
||||||
q = newname;
|
q = newname;
|
||||||
|
|
|
@ -117,6 +117,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "c.h"
|
#include "c.h"
|
||||||
|
#include "xalloc.h"
|
||||||
#include "nls.h"
|
#include "nls.h"
|
||||||
|
|
||||||
#if __GNU_LIBRARY__ < 5
|
#if __GNU_LIBRARY__ < 5
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include <blkid.h>
|
#include <blkid.h>
|
||||||
|
|
||||||
#include "nls.h"
|
#include "nls.h"
|
||||||
|
#include "xalloc.h"
|
||||||
#include "strtosize.h"
|
#include "strtosize.h"
|
||||||
|
|
||||||
struct wipe_desc {
|
struct wipe_desc {
|
||||||
|
@ -135,15 +136,6 @@ add_offset(struct wipe_desc *wp0, loff_t offset, int zap)
|
||||||
return wp;
|
return wp;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void *
|
|
||||||
xmalloc(size_t sz)
|
|
||||||
{
|
|
||||||
void *x = malloc(sz);
|
|
||||||
if (!x)
|
|
||||||
err(EXIT_FAILURE, _("malloc failed"));
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline char *
|
static inline char *
|
||||||
xstrdup(const char *s)
|
xstrdup(const char *s)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue