/
index
/
libcext.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
inline
| side by side (from parent 1:
de90788
)
minor asprintf refinement
author
git
<redacted>
Mon, 20 Apr 2026 08:39:39 +0000
(
04:39
-0400)
committer
git
<redacted>
Mon, 20 Apr 2026 08:39:39 +0000
(
04:39
-0400)
asprintf.h
patch
|
blob
|
history
diff --git
a/asprintf.h
b/asprintf.h
index 6d3341ae7c27f85aaa87bca5a839b294eff21e6e..fc66ba5c294603abe39add0fe8810167bf863d2e 100644
(file)
--- a/
asprintf.h
+++ b/
asprintf.h
@@
-29,59
+29,59
@@
#ifndef ASPRINTF_H_
#define ASPRINTF_H_ 1
#ifndef ASPRINTF_H_
#define ASPRINTF_H_ 1
-
#ifdef ASPRINTF_INCLUDE_LIBC
+#ifdef ASPRINTF_INCLUDE_LIBC
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
-
#endif /* ASPRINTF_INCLUDE_LIBC */
+#endif /* ASPRINTF_INCLUDE_LIBC */
-
#ifndef HAVE_ASPRINTF
+#ifndef HAVE_ASPRINTF
#define HAVE_ASPRINTF 1
#define asprintf i_asprintf_
#define vasprintf i_vasprintf_
#define HAVE_ASPRINTF 1
#define asprintf i_asprintf_
#define vasprintf i_vasprintf_
- int i_vasprintf_(char **
restrict strp, const char *restrict
fmt, va_list ap);
- int i_asprintf_(char **
restrict strp, const char *restrict
fmt, ...);
-
#endif /* !HAVE_ASPRINTF */
+ int i_vasprintf_(char **
strp, const char *
fmt, va_list ap);
+ int i_asprintf_(char **
strp, const char *
fmt, ...);
+#endif /* !HAVE_ASPRINTF */
-
#ifdef ASPRINTF_IMPLEMENTATION
-
int
-
i_vasprintf_(char **restrict strp, const char *restrict
fmt, va_list ap)
-
{
-
int size, ret;
-
va_list tp;
+#ifdef ASPRINTF_IMPLEMENTATION
+int
+
i_vasprintf_(char **strp, const char *
fmt, va_list ap)
+{
+ int size, ret;
+ va_list tp;
-
va_copy(tp, ap);
-
size = vsnprintf(NULL, 0, fmt, tp);
-
va_end(tp);
+ va_copy(tp, ap);
+ size = vsnprintf(NULL, 0, fmt, tp);
+ va_end(tp);
-
if (size < 0) {
-
return -1;
-
}
-
*strp = malloc(size + 1);
-
if (*strp == NULL) {
-
return -1;
-
}
+ if (size < 0) {
+ return -1;
+ }
+ *strp = malloc(size + 1);
+ if (*strp == NULL) {
+ return -1;
+ }
-
ret = vsnprintf(*strp, size + 1, fmt, ap);
-
if (ret < 0) {
-
free(*strp);
-
return -1;
-
}
+ ret = vsnprintf(*strp, size + 1, fmt, ap);
+ if (ret < 0) {
+ free(*strp);
+ return -1;
+ }
-
return ret;
-
}
+ return ret;
+}
-
int
-
i_asprintf_(char **restrict strp, const char *restrict
fmt, ...)
-
{
-
int ret;
-
va_list ap;
+int
+
i_asprintf_(char **strp, const char *
fmt, ...)
+{
+ int ret;
+ va_list ap;
-
va_start(ap, fmt);
-
ret = i_vasprintf_(strp, fmt, ap);
-
va_end(ap);
+ va_start(ap, fmt);
+ ret = i_vasprintf_(strp, fmt, ap);
+ va_end(ap);
-
return ret;
-
}
-
#endif /* ASPRINTF_IMPLEMENTATION */
+ return ret;
+}
+#endif /* ASPRINTF_IMPLEMENTATION */
#endif /* !ASPRINTF_H_ */
#endif /* !ASPRINTF_H_ */