summaryrefslogtreecommitdiff
path: root/include/apr_strings.h
diff options
context:
space:
mode:
authorWilliam A. Rowe Jr <wrowe@apache.org>2001-12-02 09:20:23 +0000
committerWilliam A. Rowe Jr <wrowe@apache.org>2001-12-02 09:20:23 +0000
commit896586901cbdf81fe5fc2df53913a724f8549d71 (patch)
tree8dd923f5d6153e454ca8219ce97684278a68ac2e /include/apr_strings.h
parent7f7ffca1f64032cb6252c9c243c17d7ed271c849 (diff)
downloadapr-896586901cbdf81fe5fc2df53913a724f8549d71.tar.gz
This patch adds a function apr_strmemdup(), which works like
apr_pstrndup() except that it's optimized for the case where the caller can guarantee that the length of the supplied string is >= 'n' Submitted by: Brian Pane <bpane@pacbell.net> git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@62594 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'include/apr_strings.h')
-rw-r--r--include/apr_strings.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/include/apr_strings.h b/include/apr_strings.h
index e409896a2..9c814eb02 100644
--- a/include/apr_strings.h
+++ b/include/apr_strings.h
@@ -128,6 +128,20 @@ APR_DECLARE(int) apr_strnatcasecmp(char const *a, char const *b);
APR_DECLARE(char *) apr_pstrdup(apr_pool_t *p, const char *s);
/**
+ * Create a null-terminated string by making a copy of a sequence
+ * of characters and appending a null byte
+ * @param p The pool to allocate out of
+ * @param s The block of characters to duplicate
+ * @param n The number of characters to duplicate
+ * @return The new string
+ * @remark This is a faster alternative to apr_pstrndup, for use
+ * when you know that the string being duplicated really
+ * has 'n' or more characters. If the string might contain
+ * fewer characters, use apr_pstrndup.
+ */
+APR_DECLARE(char *) apr_pstrmemdup(apr_pool_t *p, const char *s, apr_size_t n);
+
+/**
* duplicate the first n characters of a string into memory allocated
* out of a pool; the new string will be '\0'-terminated
* @param p The pool to allocate out of