/
githubmirror
/
ndctl
Обзор
Документация
Войти
/
githubmirror
/
ndctl
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
v84
util/wrapper.c
39 строк
693 B
Vishal Verma
util/wrapper.c: Fix gcc warning in xrealloc()
16 июн 2022, 23:36
16 июн 2022, 23:36
bbb2cb5
Код
Авторство
О чём код?
// SPDX-License-Identifier: GPL-2.0 // Copyright (C) 2005 Junio C Hamano. All rights reserved. // Copyright (C) 2005 Linus Torvalds. All rights reserved. /* originally copied from perf and git */ /* * Various trivial helper wrappers around standard functions */ #include <string.h> #include <stdlib.h> #include <util/util.h> char *xstrdup(const char *str) { char *ret = strdup(str); if (!ret) { ret = strdup(str); if (!ret) die("Out of memory, strdup failed"); } return ret; } void *xrealloc(void *ptr, size_t size) { void *ret; if (!size) { free(ptr); return malloc(1); } ret = realloc(ptr, size); if (!ret) die("Out of memory, realloc failed"); return ret; }