Changeset 8598 for trunk/psLib/src/sys/psString.c
- Timestamp:
- Aug 25, 2006, 11:50:07 AM (20 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/sys/psString.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/sys/psString.c
r8415 r8598 13 13 * @author David Robbins, MHPCC 14 14 * 15 * @version $Revision: 1.4 1$ $Name: not supported by cvs2svn $16 * @date $Date: 2006-08- 18 01:59:13$15 * @version $Revision: 1.42 $ $Name: not supported by cvs2svn $ 16 * @date $Date: 2006-08-25 21:50:07 $ 17 17 * 18 18 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 98 98 ...) 99 99 { 100 va_list ap; 101 va_start(ap, format); 102 ssize_t length = psStringAppendV(dest, format, ap); 103 va_end(ap); 104 105 return length; 106 } 107 108 ssize_t psStringAppendV(char **dest, 109 const char *format, 110 va_list ap) 111 { 100 112 PS_ASSERT_PTR_NON_NULL(format, 0); 101 va_list args;102 113 size_t length; // complete string length (sans \0) 103 114 size_t oldLength; // original string length (sans \0) … … 115 126 116 127 // find the size of the string to append 117 va_ start(args, format);128 va_list apCopy; 118 129 // C99 guarentees vsnprintf() to work as expected with size = 0 119 tailLength = vsnprintf(*dest, 0, format, args); 120 va_end(args); 130 va_copy(apCopy, ap); 131 tailLength = vsnprintf(*dest, 0, format, apCopy); 132 va_end(apCopy); 121 133 122 134 // if the new tail is zero length, return the length of the old string. if … … 134 146 135 147 // append tail + \0 136 va_start(args, format); 137 vsnprintf(*dest + oldLength, tailLength + 1, format, args); 138 va_end(args); 148 // XXX this second call to va_copy() isn't strictly nessicary as the 149 // calling function can't assume we won't modify the va_list. However, we 150 // have decided to error on the side of caution. 151 va_copy(apCopy, ap); 152 vsnprintf(*dest + oldLength, tailLength + 1, format, apCopy); 153 va_end(apCopy); 139 154 140 155 return length;
Note:
See TracChangeset
for help on using the changeset viewer.
