1 /* Copyright 1998 by Andi Kleen. Subject to the GPL. */
2 /* $Id: util.c,v 1.4 1998/11/17 15:17:02 freitag Exp $ */
6 #include <sys/utsname.h>
13 fprintf(stderr
, "out of virtual memory\n");
17 void *xmalloc(size_t sz
)
19 void *p
= calloc(sz
, 1);
25 void *xrealloc(void *oldp
, size_t sz
)
27 void *p
= realloc(oldp
, sz
);
33 int kernel_version(void)
36 int major
, minor
, patch
;
40 if (sscanf(uts
.release
, "%d.%d.%d", &major
, &minor
, &patch
) != 3)
42 return KRELEASE(major
, minor
, patch
);
46 /* Like strncpy but make sure the resulting string is always 0 terminated. */
47 char *safe_strncpy(char *dst
, const char *src
, size_t size
)
50 return strncpy(dst
,src
,size
-1);