From 06eb436008270420b10ed748c9f83c3d5464ff94 Mon Sep 17 00:00:00 2001 From: Petri Lehtinen Date: Sun, 5 Sep 2010 20:54:37 +0300 Subject: [PATCH] Move max() to jansson_private.h, define only if not already defined On some platforms (Visual C++ for one) the standard library already defines max() as a macro. --- src/Makefile.am | 1 - src/jansson_private.h | 5 +++++ src/strbuffer.c | 2 +- src/util.h | 13 ------------- src/value.c | 1 - 5 files changed, 6 insertions(+), 16 deletions(-) delete mode 100644 src/util.h diff --git a/src/Makefile.am b/src/Makefile.am index 907631d..635176e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -11,7 +11,6 @@ libjansson_la_SOURCES = \ strbuffer.h \ utf.c \ utf.h \ - util.h \ value.c libjansson_la_LDFLAGS = \ -export-symbols-regex '^json_' \ diff --git a/src/jansson_private.h b/src/jansson_private.h index e9e0097..e9102ba 100644 --- a/src/jansson_private.h +++ b/src/jansson_private.h @@ -15,6 +15,11 @@ #define container_of(ptr_, type_, member_) \ ((type_ *)((char *)ptr_ - offsetof(type_, member_))) +/* On some platforms, max() may already be defined */ +#ifndef max +#define max(a, b) ((a) > (b) ? (a) : (b)) +#endif + typedef struct { json_t json; hashtable_t hashtable; diff --git a/src/strbuffer.c b/src/strbuffer.c index 3496024..4e866bd 100644 --- a/src/strbuffer.c +++ b/src/strbuffer.c @@ -8,8 +8,8 @@ #define _GNU_SOURCE #include #include +#include "jansson_private.h" #include "strbuffer.h" -#include "util.h" #define STRBUFFER_MIN_SIZE 16 #define STRBUFFER_FACTOR 2 diff --git a/src/util.h b/src/util.h deleted file mode 100644 index 06a547b..0000000 --- a/src/util.h +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (c) 2009, 2010 Petri Lehtinen - * - * Jansson is free software; you can redistribute it and/or modify - * it under the terms of the MIT license. See LICENSE for details. - */ - -#ifndef UTIL_H -#define UTIL_H - -#define max(a, b) ((a) > (b) ? (a) : (b)) - -#endif diff --git a/src/value.c b/src/value.c index 75236b4..89d7b71 100644 --- a/src/value.c +++ b/src/value.c @@ -15,7 +15,6 @@ #include "hashtable.h" #include "jansson_private.h" #include "utf.h" -#include "util.h" static JSON_INLINE void json_init(json_t *json, json_type type) -- 2.1.4