Skip to content

Commit b90ed1a

Browse files
committed
Enhance portability of va_copy()
va_copy() is a C99 feature. In C89 implementations, it's sometimes available as __va_copy(). If not, memcpy() should do the trick.
1 parent 1111960 commit b90ed1a

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/jansson_private.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#define JANSSON_PRIVATE_H
1010

1111
#include <stddef.h>
12-
#include <stdarg.h>
1312
#include "jansson.h"
1413
#include "hashtable.h"
1514

@@ -21,6 +20,16 @@
2120
#define max(a, b) ((a) > (b) ? (a) : (b))
2221
#endif
2322

23+
/* va_copy is a C99 feature. In C89 implementations, it's sometimes
24+
available as __va_copy. If not, memcpy() should do the trick. */
25+
#ifndef va_copy
26+
#ifdef __va_copy
27+
#define va_copy __va_copy
28+
#else
29+
#define va_copy(a, b) memcpy(&(a), &(b), sizeof(va_list))
30+
#endif
31+
#endif
32+
2433
typedef struct {
2534
json_t json;
2635
hashtable_t hashtable;

src/load.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include <stdio.h>
1313
#include <stdlib.h>
1414
#include <string.h>
15-
#include <stdarg.h>
1615
#include <assert.h>
1716

1817
#include <jansson.h>

0 commit comments

Comments
 (0)