ObjFW  Check-in [07f4a82038]

Overview
Comment:of_asprintf: Fix type mismatch on LP64 systems
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 07f4a82038ea9a147e65a09174cf3ceeee211a93ed8c3b31f987eefc367f69a2
User & Date: js on 2021-01-31 15:16:36
Other Links: manifest | tags
Context
2021-01-31
23:52
Revert lookup-asm-x86_64-macho.S to AT&T syntax check-in: b57d18acaa user: js tags: trunk
15:16
of_asprintf: Fix type mismatch on LP64 systems check-in: 07f4a82038 user: js tags: trunk
2021-01-30
20:21
Revert apple-forwarding-*.S back to AT&T syntax check-in: a6eb951b8c user: js tags: trunk
Changes

Modified src/of_asprintf.m from [489f8ebee0] to [d2e16772ed].

93
94
95
96
97
98
99

100
101
102
103
104
105
106
107
}
#endif

#ifndef HAVE_ASPRINTF
static int
vasprintf(char **string, const char *format, va_list arguments)
{

	size_t length, bufferLength = 128;

	*string = NULL;

	for (;;) {
		free(*string);

		if ((*string = malloc(bufferLength)) == NULL)







>
|







93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
}
#endif

#ifndef HAVE_ASPRINTF
static int
vasprintf(char **string, const char *format, va_list arguments)
{
	int length;
	size_t bufferLength = 128;

	*string = NULL;

	for (;;) {
		free(*string);

		if ((*string = malloc(bufferLength)) == NULL)
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
			free(*string);
			return -1;
		}

		bufferLength <<= 1;
	}

	if (length != bufferLength - 1) {
		char *resized = realloc(*string, length + 1);

		/* Ignore if making it smaller failed. */
		if (resized != NULL)
			*string = resized;
	}








|







118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
			free(*string);
			return -1;
		}

		bufferLength <<= 1;
	}

	if (length > 0 && (size_t)length != bufferLength - 1) {
		char *resized = realloc(*string, length + 1);

		/* Ignore if making it smaller failed. */
		if (resized != NULL)
			*string = resized;
	}