File: mprintf.c

package info (click to toggle)
reprepro 1.3.1%2B1-1
  • links: PTS
  • area: main
  • in suites: etch
  • size: 1,660 kB
  • ctags: 1,621
  • sloc: ansic: 22,424; sh: 2,032; python: 138; makefile: 127
file content (36 lines) | stat: -rw-r--r-- 621 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <config.h>

#include <stdio.h>
#include <stdarg.h>

#include "mprintf.h"

// TODO: check for asprintf in configure and
// write a replacement for such situations.

char * mprintf(const char *fmt,...) {
	char *p;
	int r;
	va_list va;

	va_start(va,fmt);
	r = vasprintf(&p,fmt,va);
	va_end(va);
	/* return NULL both when r is < 0 and when NULL was returned */
	if( r < 0 )
		return NULL;
	else
		return p;
}

char * vmprintf(const char *fmt,va_list va) {
	char *p;
	int r;

	r = vasprintf(&p,fmt,va);
	/* return NULL both when r is < 0 and when NULL was returned */
	if( r < 0 )
		return NULL;
	else
		return p;
}