From 175bc40deeefb3a385012d3f9a3874e8b3c46d97 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 3 Apr 2021 10:35:08 +0200 Subject: Add pure attributes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- common.h | 7 +++++++ libcontacts_parse_contact.c | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/common.h b/common.h index ab021cc..5bb22a1 100644 --- a/common.h +++ b/common.h @@ -14,6 +14,13 @@ #include +#if defined(__GNUC__) || defined(__clang__) +# define ATTRIBUTE_PURE __attribute__((__pure__)) +#else +# define ATTRIBUTE_PURE +#endif + + #define TIME_MAX ((time_t)((1ULL << (8 * sizeof(time_t) - 1)) - 1ULL)) diff --git a/libcontacts_parse_contact.c b/libcontacts_parse_contact.c index f8de012..79dc579 100644 --- a/libcontacts_parse_contact.c +++ b/libcontacts_parse_contact.c @@ -2,6 +2,7 @@ #include "common.h" +ATTRIBUTE_PURE static time_t gettime(const char *data) { @@ -18,6 +19,7 @@ gettime(const char *data) return ret; } +ATTRIBUTE_PURE static unsigned int getposuint(const char *data) { @@ -34,6 +36,7 @@ getposuint(const char *data) return ret; } +ATTRIBUTE_PURE static unsigned char getposuchar(const char *data) { @@ -50,6 +53,7 @@ getposuchar(const char *data) return ret; } +ATTRIBUTE_PURE static char * getstr(char *data) { @@ -57,6 +61,7 @@ getstr(char *data) return &strchr(data, ' ')[1]; } +ATTRIBUTE_PURE static char * unindent(char *data) { -- cgit v1.2.3-70-g09d2