- deraadt 2001/02/07 8:57:26
[xmalloc.c] deal with new ANSI malloc stuff - markus@cvs.openbsd.org 2001/02/07 16:46:08 [xmalloc.c] typo in fatal() - itojun@cvs.openbsd.org 2001/02/07 18:04:50 [xmalloc.c] fix size_t -> int cast (use u_long). markus ok
This commit is contained in:
parent
70ea46a382
commit
a905ecd994
11
ChangeLog
11
ChangeLog
|
@ -83,6 +83,15 @@
|
||||||
- deraadt@cvs.openbsd.org 2001/02/06 22:07:50
|
- deraadt@cvs.openbsd.org 2001/02/06 22:07:50
|
||||||
[sshd_config]
|
[sshd_config]
|
||||||
enable sftp-server by default
|
enable sftp-server by default
|
||||||
|
- deraadt 2001/02/07 8:57:26
|
||||||
|
[xmalloc.c]
|
||||||
|
deal with new ANSI malloc stuff
|
||||||
|
- markus@cvs.openbsd.org 2001/02/07 16:46:08
|
||||||
|
[xmalloc.c]
|
||||||
|
typo in fatal()
|
||||||
|
- itojun@cvs.openbsd.org 2001/02/07 18:04:50
|
||||||
|
[xmalloc.c]
|
||||||
|
fix size_t -> int cast (use u_long). markus ok
|
||||||
- (bal) fixed sftp-client.c. Return 'status' instead of '0'
|
- (bal) fixed sftp-client.c. Return 'status' instead of '0'
|
||||||
(from the OpenBSD tree)
|
(from the OpenBSD tree)
|
||||||
- (bal) Synced ssh.1, ssh-add.1 and sshd.8 w/ OpenBSD
|
- (bal) Synced ssh.1, ssh-add.1 and sshd.8 w/ OpenBSD
|
||||||
|
@ -3871,4 +3880,4 @@
|
||||||
- Wrote replacements for strlcpy and mkdtemp
|
- Wrote replacements for strlcpy and mkdtemp
|
||||||
- Released 1.0pre1
|
- Released 1.0pre1
|
||||||
|
|
||||||
$Id: ChangeLog,v 1.735 2001/02/10 23:30:16 mouring Exp $
|
$Id: ChangeLog,v 1.736 2001/02/10 23:34:54 mouring Exp $
|
||||||
|
|
19
xmalloc.c
19
xmalloc.c
|
@ -13,7 +13,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
RCSID("$OpenBSD: xmalloc.c,v 1.11 2001/02/04 15:32:27 stevesk Exp $");
|
RCSID("$OpenBSD: xmalloc.c,v 1.14 2001/02/07 18:04:50 itojun Exp $");
|
||||||
|
|
||||||
#include "xmalloc.h"
|
#include "xmalloc.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
@ -21,9 +21,13 @@ RCSID("$OpenBSD: xmalloc.c,v 1.11 2001/02/04 15:32:27 stevesk Exp $");
|
||||||
void *
|
void *
|
||||||
xmalloc(size_t size)
|
xmalloc(size_t size)
|
||||||
{
|
{
|
||||||
void *ptr = malloc(size);
|
void *ptr;
|
||||||
|
|
||||||
|
if (size == 0)
|
||||||
|
fatal("xmalloc: zero size");
|
||||||
|
ptr = malloc(size);
|
||||||
if (ptr == NULL)
|
if (ptr == NULL)
|
||||||
fatal("xmalloc: out of memory (allocating %d bytes)", (int) size);
|
fatal("xmalloc: out of memory (allocating %lu bytes)", (u_long) size);
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,11 +36,13 @@ xrealloc(void *ptr, size_t new_size)
|
||||||
{
|
{
|
||||||
void *new_ptr;
|
void *new_ptr;
|
||||||
|
|
||||||
|
if (new_size == 0)
|
||||||
|
fatal("xrealloc: zero size");
|
||||||
if (ptr == NULL)
|
if (ptr == NULL)
|
||||||
fatal("xrealloc: NULL pointer given as argument");
|
fatal("xrealloc: NULL pointer given as argument");
|
||||||
new_ptr = realloc(ptr, new_size);
|
new_ptr = realloc(ptr, new_size);
|
||||||
if (new_ptr == NULL)
|
if (new_ptr == NULL)
|
||||||
fatal("xrealloc: out of memory (new_size %d bytes)", (int) new_size);
|
fatal("xrealloc: out of memory (new_size %lu bytes)", (u_long) new_size);
|
||||||
return new_ptr;
|
return new_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,8 +58,11 @@ char *
|
||||||
xstrdup(const char *str)
|
xstrdup(const char *str)
|
||||||
{
|
{
|
||||||
size_t len = strlen(str) + 1;
|
size_t len = strlen(str) + 1;
|
||||||
|
char *cp;
|
||||||
|
|
||||||
char *cp = xmalloc(len);
|
if (len == 0)
|
||||||
|
fatal("xstrdup: zero size");
|
||||||
|
cp = xmalloc(len);
|
||||||
strlcpy(cp, str, len);
|
strlcpy(cp, str, len);
|
||||||
return cp;
|
return cp;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue