diff options
author | Haru <haru@dotalux.com> | 2016-02-22 20:55:20 +0100 |
---|---|---|
committer | Haru <haru@dotalux.com> | 2016-02-24 19:40:32 +0100 |
commit | 931d716e1000b50a66b012815a412619d16fc957 (patch) | |
tree | c49200ddb3d4ee9bd3cd5081822edf657c926f72 /src/common/memmgr.h | |
parent | 7fd9e649fbcdef4abe7e9e77c24871e485262ca3 (diff) | |
download | hercules-931d716e1000b50a66b012815a412619d16fc957.tar.gz hercules-931d716e1000b50a66b012815a412619d16fc957.tar.bz2 hercules-931d716e1000b50a66b012815a412619d16fc957.tar.xz hercules-931d716e1000b50a66b012815a412619d16fc957.zip |
Implemented aStrndup()
- aStrndup() behaves similarly to the POSIX function strdup(). It
allocates sufficient memory for a copy of the passed string, copies
it, and returns a pointer to the copy. A maximum number of characters
is copied (and a NUL terminator is always appended after the end).
Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/common/memmgr.h')
-rw-r--r-- | src/common/memmgr.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/common/memmgr.h b/src/common/memmgr.h index 5975f55c4..680947466 100644 --- a/src/common/memmgr.h +++ b/src/common/memmgr.h @@ -52,6 +52,7 @@ # define aRealloc(p,n) (iMalloc->realloc((p),(n),ALC_MARK)) # define aReallocz(p,n) (iMalloc->reallocz((p),(n),ALC_MARK)) # define aStrdup(p) (iMalloc->astrdup((p),ALC_MARK)) +# define aStrndup(p,n) (iMalloc->astrndup((p),(n),ALC_MARK)) # define aFree(p) (iMalloc->free((p),ALC_MARK)) /////////////// Buffer Creation ///////////////// @@ -85,6 +86,7 @@ struct malloc_interface { void* (*realloc)(void *p, size_t size, const char *file, int line, const char *func); void* (*reallocz)(void *p, size_t size, const char *file, int line, const char *func); char* (*astrdup)(const char *p, const char *file, int line, const char *func); + char *(*astrndup)(const char *p, size_t size, const char *file, int line, const char *func); void (*free)(void *p, const char *file, int line, const char *func); /* */ void (*memory_check)(void); |