apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b..@apache.org
Subject cvs commit: apr/strings apr_strings.c
Date Sun, 11 Feb 2001 16:18:09 GMT
ben         01/02/11 08:18:09

  Modified:    include  apr_strings.h
               strings  apr_strings.c
  Log:
  Add memdup function.
  
  Revision  Changes    Path
  1.11      +12 -2     apr/include/apr_strings.h
  
  Index: apr_strings.h
  ===================================================================
  RCS file: /home/cvs/apr/include/apr_strings.h,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- apr_strings.h	2001/02/11 00:12:11	1.10
  +++ apr_strings.h	2001/02/11 16:18:08	1.11
  @@ -120,7 +120,7 @@
   /**
    * duplicate a string into memory allocated out of a pool
    * @param p The pool to allocate out of
  - * @param s The string to allocate
  + * @param s The string to duplicate
    * @return The new string
    * @deffunc char *apr_pstrdup(apr_pool_t *p, const char *s)
    */
  @@ -130,12 +130,22 @@
    * 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
  - * @param s The string to allocate
  + * @param s The string to duplicate
    * @param n The number of characters to duplicate
    * @return The new string
    * @deffunc char *apr_pstrndup(apr_pool_t *p, const char *s, apr_size_t n)
    */
   APR_DECLARE(char *) apr_pstrndup(apr_pool_t *p, const char *s, apr_size_t n);
  +
  +/**
  + * Duplicate a block of memory.
  + *
  + * @param p The pool to allocate from
  + * @param m The memory to duplicate
  + * @param n The number of bytes to duplicate
  + * @return The new block of memory
  + */
  +APR_DECLARE(void *) apr_memdup(apr_pool_t *p, const void *m, apr_size_t n);
   
   /**
    * Concatenate multiple strings, allocating memory out a pool
  
  
  
  1.8       +11 -0     apr/strings/apr_strings.c
  
  Index: apr_strings.c
  ===================================================================
  RCS file: /home/cvs/apr/strings/apr_strings.c,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- apr_strings.c	2001/01/28 08:18:32	1.7
  +++ apr_strings.c	2001/02/11 16:18:09	1.8
  @@ -93,6 +93,17 @@
       return res;
   }
   
  +APR_DECLARE(void *) apr_memdup(apr_pool_t *a, const void *m, apr_size_t n)
  +{
  +    void *res;
  +
  +    if(m == NULL)
  +	return NULL;
  +    res = apr_palloc(a, n);
  +    memcpy(res, m, n);
  +    return res;
  +}
  +
   APR_DECLARE_NONSTD(char *) apr_pstrcat(apr_pool_t *a, ...)
   {
       char *cp, *argp, *res;
  
  
  

Mime
View raw message