mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-24 03:08:51 +03:00
Update to onnv_147
This is the last official OpenSolaris tag before the public development tree was closed.
This commit is contained in:
+39
-2
@@ -19,8 +19,7 @@
|
||||
* CDDL HEADER END
|
||||
*/
|
||||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
|
||||
#include "libuutil_common.h"
|
||||
@@ -67,6 +66,44 @@ uu_strdup(const char *str)
|
||||
return (buf);
|
||||
}
|
||||
|
||||
/*
|
||||
* Duplicate up to n bytes of a string. Kind of sort of like
|
||||
* strdup(strlcpy(s, n)).
|
||||
*/
|
||||
char *
|
||||
uu_strndup(const char *s, size_t n)
|
||||
{
|
||||
size_t len;
|
||||
char *p;
|
||||
|
||||
len = strnlen(s, n);
|
||||
p = uu_zalloc(len + 1);
|
||||
if (p == NULL)
|
||||
return (NULL);
|
||||
|
||||
if (len > 0)
|
||||
(void) memcpy(p, s, len);
|
||||
p[len] = '\0';
|
||||
|
||||
return (p);
|
||||
}
|
||||
|
||||
/*
|
||||
* Duplicate a block of memory. Combines malloc with memcpy, much as
|
||||
* strdup combines malloc, strlen, and strcpy.
|
||||
*/
|
||||
void *
|
||||
uu_memdup(const void *buf, size_t sz)
|
||||
{
|
||||
void *p;
|
||||
|
||||
p = uu_zalloc(sz);
|
||||
if (p == NULL)
|
||||
return (NULL);
|
||||
(void) memcpy(p, buf, sz);
|
||||
return (p);
|
||||
}
|
||||
|
||||
char *
|
||||
uu_msprintf(const char *format, ...)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user