[go: up one dir, main page]

Menu

[8b793c]: / util.c  Maximize  Restore  History

Download this file

61 lines (47 with data), 1.5 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/* Mis-connector - user-space router and NATP for misconfigured hosts on LAN.
Miscelanous garbage.
This file is part of mis-connector.
Copyright (C) 2004,2021 Petr Silhavy <petr.silhavy@yandex.com>
SPDX-License-Identifier: GPL-3.0-or-later
Mis-connector is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 3 of the
License, or (at your option) any later version.
Mis-connector is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with mis-connector. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include "whackparam.h"
void
_fail(char *file,int line,char *fce,char *msg,char *opt,int exit_now)
{
fprintf(stderr,"FAIL: %s:%d %s() %s [%s] - %s errno %d\n",
file,line,fce,
msg, opt ? opt : "" ,
strerror(errno), errno );
if ( exit_now )
abort();
}
void *
Malloc(size_t size)
{
void *r ;
if ( ( r = malloc(size)) == NULL )
BUG("malloc failed");
return r ;
}
void *
Malloc0(size_t size)
{
void *r = Malloc(size);
memset(r, 0, size);
return r ;
}