ObjFW  Check-in [3e4e1a46a0]

Overview
Comment:Fix off by one.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 3e4e1a46a04541d6831173130627b0c204ae3f096d0be11b07fe23e98d29ee73
User & Date: js on 2008-12-13 20:24:47
Other Links: manifest | tags
Context
2008-12-13
21:34
Always delete temp symlinks, even if test fails. Plus one new test. check-in: 15ddecd17d user: js tags: trunk
20:24
Fix off by one. check-in: 3e4e1a46a0 user: js tags: trunk
19:43
Add ${PROG_SUFFIX} to test binaries & symlinks.
One day, we can run those tests with wine when crossbuilding and native
when building using cygwin.
check-in: 034b0dc532 user: js tags: trunk
Changes

Modified src/asprintf.c from [d3bfd74e8f] to [f03277aeb4].

15
16
17
18
19
20
21
22
23
24
25
26
27

28
29
30
31
32
33
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>

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

	va_start(args, fmt);

	size = vsnprintf(NULL, 0, fmt, args);

	if ((*strp = malloc(size)) == NULL)
		return -1;

	return vsnprintf(*strp, size, fmt, args);
}
#endif







|




|
>
|


|


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#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);
}
#endif