ObjFW  Check-in [f9202dfdaf]

Overview
Comment:Add missing va_end to asprintf.c.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: f9202dfdaf54d9d122ad1fd3a919b7e5f890a803c0f7f5331675a7acc4bf75f8
User & Date: js on 2008-12-22 23:17:43
Other Links: manifest | tags
Context
2008-12-23
01:57
Check for SIZE_T, fallback to SIZE_T_MAX or define as (size_t)-1. check-in: c180b76560 user: js tags: trunk
2008-12-22
23:17
Add missing va_end to asprintf.c. check-in: f9202dfdaf user: js tags: trunk
22:30
%zd doesn't work on win32. check-in: 6362f9c167 user: js tags: trunk
Changes

Modified src/asprintf.c from [c7322870d9] to [4b720653cd].

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31

32


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

int
asprintf(char **strp, const char *fmt, ...)
{
	int size;
	va_list args;

	va_start(args, fmt);

	if ((size = vsnprintf(NULL, 0, fmt, args)) < 0)
		return size;
	if ((*strp = malloc((size_t)size + 1)) == NULL)
		return -1;

	return vsnprintf(*strp, (size_t)size + 1, fmt, args);

}









|









|
>
|
>
>
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>

int
asprintf(char **strp, const char *fmt, ...)
{
	int ret, size;
	va_list args;

	va_start(args, fmt);

	if ((size = vsnprintf(NULL, 0, fmt, args)) < 0)
		return size;
	if ((*strp = malloc((size_t)size + 1)) == NULL)
		return -1;

	ret = vsnprintf(*strp, (size_t)size + 1, fmt, args);
	va_end(args);

	return ret;
}