OLD | NEW |
1 diff -c -r talloc-2.0.1/talloc.c talloc/talloc.c | 1 diff -c -r talloc-2.0.1/talloc.c talloc/talloc.c |
2 *** talloc-2.0.1/talloc.c Tue Dec 15 06:16:57 2009 | 2 *** talloc-2.0.1/talloc.c Tue Dec 15 06:16:57 2009 |
3 --- talloc/talloc.c» Mon Oct 25 13:58:42 2010 | 3 --- talloc/talloc.c» Fri Mar 18 13:03:11 2011 |
4 *************** | 4 *************** |
5 *** 30,36 **** | 5 *** 30,36 **** |
6 inspired by http://swapped.cc/halloc/ | 6 inspired by http://swapped.cc/halloc/ |
7 */ | 7 */ |
8 | 8 |
9 ! #include "replace.h" | 9 ! #include "replace.h" |
10 #include "talloc.h" | 10 #include "talloc.h" |
11 | 11 |
12 #ifdef TALLOC_BUILD_VERSION_MAJOR | 12 #ifdef TALLOC_BUILD_VERSION_MAJOR |
13 --- 30,37 ---- | 13 --- 30,37 ---- |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 char *ret; | 278 char *ret; |
279 --- 1613,1619 ---- | 279 --- 1613,1619 ---- |
280 return __talloc_strlendup(t, p, strnlen(p, n)); | 280 return __talloc_strlendup(t, p, strnlen(p, n)); |
281 } | 281 } |
282 | 282 |
283 ! static INLINE char *__talloc_strlendup_append(char *s, size_t slen, | 283 ! static INLINE char *__talloc_strlendup_append(char *s, size_t slen, |
284 const char *a, size_t alen) | 284 const char *a, size_t alen) |
285 { | 285 { |
286 char *ret; | 286 char *ret; |
287 *************** | 287 *************** |
288 *** 1736,1749 **** | 288 *** 1699,1709 **** |
| 289 » int len; |
| 290 » char *ret; |
| 291 » va_list ap2; |
| 292 - » char c; |
| 293 |
| 294 - » /* this call looks strange, but it makes it work on older solaris boxes
*/ |
| 295 » va_copy(ap2, ap); |
| 296 ! » len = vsnprintf(&c, 1, fmt, ap2); |
| 297 » va_end(ap2); |
| 298 » if (unlikely(len < 0)) { |
| 299 » » return NULL; |
| 300 --- 1722,1730 ---- |
| 301 » int len; |
| 302 » char *ret; |
| 303 » va_list ap2; |
| 304 |
| 305 » va_copy(ap2, ap); |
| 306 ! » len = vsnprintf(NULL, 0, fmt, ap2); |
| 307 » va_end(ap2); |
| 308 » if (unlikely(len < 0)) { |
| 309 » » return NULL; |
| 310 *************** |
| 311 *** 1736,1754 **** |
289 return ret; | 312 return ret; |
290 } | 313 } |
291 | 314 |
292 ! static inline char *__talloc_vaslenprintf_append(char *s, size_t slen, | 315 ! static inline char *__talloc_vaslenprintf_append(char *s, size_t slen, |
293 const char *fmt, va_list ap) | 316 const char *fmt, va_list ap) |
294 PRINTF_ATTRIBUTE(3,0); | 317 PRINTF_ATTRIBUTE(3,0); |
295 | 318 |
296 ! static inline char *__talloc_vaslenprintf_append(char *s, size_t slen, | 319 ! static inline char *__talloc_vaslenprintf_append(char *s, size_t slen, |
297 const char *fmt, va_list ap) | 320 const char *fmt, va_list ap) |
298 { | 321 { |
299 ssize_t alen; | 322 ssize_t alen; |
300 va_list ap2; | 323 va_list ap2; |
301 » char c; | 324 - » char c; |
302 | 325 |
303 --- 1759,1777 ---- | 326 » va_copy(ap2, ap); |
| 327 ! » alen = vsnprintf(&c, 1, fmt, ap2); |
| 328 » va_end(ap2); |
| 329 |
| 330 » if (alen <= 0) { |
| 331 --- 1757,1779 ---- |
304 return ret; | 332 return ret; |
305 } | 333 } |
306 | 334 |
307 ! static INLINE char *__talloc_vaslenprintf_append(char *s, size_t slen, | 335 ! static INLINE char *__talloc_vaslenprintf_append(char *s, size_t slen, |
308 const char *fmt, va_list ap) | 336 const char *fmt, va_list ap) |
309 PRINTF_ATTRIBUTE(3,0); | 337 PRINTF_ATTRIBUTE(3,0); |
310 | 338 |
311 ! static INLINE char *__talloc_vaslenprintf_append(char *s, size_t slen, | 339 ! static INLINE char *__talloc_vaslenprintf_append(char *s, size_t slen, |
312 const char *fmt, va_list ap) | 340 const char *fmt, va_list ap) |
313 { | 341 { |
314 + /* ssize_t isn't present on Windows. */ | 342 + /* ssize_t isn't present on Windows. */ |
315 + #ifndef _MSC_VER | 343 + #ifndef _MSC_VER |
316 ssize_t alen; | 344 ssize_t alen; |
317 + #else | 345 + #else |
318 + size_t alen; | 346 + size_t alen; |
319 + #endif | 347 + #endif |
320 va_list ap2; | 348 va_list ap2; |
321 char c; | |
322 | 349 |
| 350 va_copy(ap2, ap); |
| 351 ! alen = vsnprintf(NULL, 0, fmt, ap2); |
| 352 va_end(ap2); |
| 353 |
| 354 if (alen <= 0) { |
323 diff -c -r talloc-2.0.1/talloc.h talloc/talloc.h | 355 diff -c -r talloc-2.0.1/talloc.h talloc/talloc.h |
324 *** talloc-2.0.1/talloc.h Wed Oct 28 16:14:20 2009 | 356 *** talloc-2.0.1/talloc.h Wed Oct 28 16:14:20 2009 |
325 --- talloc/talloc.h» Mon Oct 25 15:11:18 2010 | 357 --- talloc/talloc.h» Fri Mar 18 13:03:02 2011 |
326 *************** | 358 *************** |
327 *** 28,33 **** | 359 *** 28,33 **** |
328 --- 28,37 ---- | 360 --- 28,37 ---- |
329 #include <stdlib.h> | 361 #include <stdlib.h> |
330 #include <stdio.h> | 362 #include <stdio.h> |
331 #include <stdarg.h> | 363 #include <stdarg.h> |
332 + #ifndef _MSC_VER | 364 + #ifndef _MSC_VER |
333 + #include <stdint.h> | 365 + #include <stdint.h> |
334 + #endif | 366 + #endif |
335 + #include <string.h> | 367 + #include <string.h> |
336 | 368 |
337 #define TALLOC_VERSION_MAJOR 2 | 369 #define TALLOC_VERSION_MAJOR 2 |
338 #define TALLOC_VERSION_MINOR 0 | 370 #define TALLOC_VERSION_MINOR 0 |
OLD | NEW |