Cygwin: mmap: allow remapping part of an existing anonymous mapping
[newlib-cygwin.git] / newlib / libc / stdio / vdiprintf.c
blob22a71b326299a28754f9bf14be7aea9c7784293d
1 /* Copyright 2005, 2007 Shaun Jackman
2 * Permission to use, copy, modify, and distribute this software
3 * is freely granted, provided that this notice is preserved.
4 */
5 /* doc in diprintf.c */
7 #include <_ansi.h>
8 #include <reent.h>
9 #include <stdio.h>
10 #include <stdlib.h>
11 #include <unistd.h>
12 #include <stdarg.h>
13 #include "local.h"
15 int
16 _vdiprintf_r (struct _reent *ptr,
17 int fd,
18 const char *format,
19 va_list ap)
21 char *p;
22 char buf[512];
23 size_t n = sizeof buf;
25 _REENT_SMALL_CHECK_INIT (ptr);
26 p = _vasniprintf_r (ptr, buf, &n, format, ap);
27 if (!p)
28 return -1;
29 n = _write_r (ptr, fd, p, n);
30 if (p != buf)
31 _free_r (ptr, p);
32 return n;
35 #ifndef _REENT_ONLY
37 int
38 vdiprintf (int fd,
39 const char *format,
40 va_list ap)
42 return _vdiprintf_r (_REENT, fd, format, ap);
45 #endif /* ! _REENT_ONLY */