[BACK]Return to rcsnum.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / cvs

Diff for /src/usr.bin/cvs/rcsnum.c between version 1.29 and 1.30

version 1.29, 2006/03/28 02:13:44 version 1.30, 2006/03/30 06:07:35
Line 38 
Line 38 
 /*  /*
  * rcsnum_alloc()   * rcsnum_alloc()
  *   *
  * Allocate an RCS number structure and return a pointer to it on success,   * Allocate an RCS number structure and return a pointer to it.
  * or NULL on failure.  
  */   */
 RCSNUM *  RCSNUM *
 rcsnum_alloc(void)  rcsnum_alloc(void)
Line 141 
Line 140 
  * rcsnum_cpy()   * rcsnum_cpy()
  *   *
  * Copy the number stored in <nsrc> in the destination <ndst> up to <depth>   * Copy the number stored in <nsrc> in the destination <ndst> up to <depth>
  * numbers deep.   * numbers deep.  If <depth> is 0, there is no depth limit.
  * Returns 0 on success, or -1 on failure.  
  */   */
 int  void
 rcsnum_cpy(const RCSNUM *nsrc, RCSNUM *ndst, u_int depth)  rcsnum_cpy(const RCSNUM *nsrc, RCSNUM *ndst, u_int depth)
 {  {
         u_int len;          u_int len;
         size_t sz;  
         void *tmp;          void *tmp;
   
         len = nsrc->rn_len;          len = nsrc->rn_len;
         if ((depth != 0) && (len > depth))          if ((depth != 0) && (len > depth))
                 len = depth;                  len = depth;
         sz = len * sizeof(u_int16_t);  
   
         tmp = xrealloc(ndst->rn_id, 1, sz);          tmp = xrealloc(ndst->rn_id, len, sizeof(len));
         ndst->rn_id = (u_int16_t *)tmp;          ndst->rn_id = (u_int16_t *)tmp;
         ndst->rn_len = len;          ndst->rn_len = len;
         memcpy(ndst->rn_id, nsrc->rn_id, sz);          /* Overflow checked in xrealloc(). */
         return (0);          memcpy(ndst->rn_id, nsrc->rn_id, len * sizeof(len));
 }  }
   
 /*  /*

Legend:
Removed from v.1.29  
changed lines
  Added in v.1.30