diff options
author | Peter Eisentraut <peter@eisentraut.org> | 2019-01-29 01:16:24 +0100 |
---|---|---|
committer | Peter Eisentraut <peter@eisentraut.org> | 2019-02-13 11:50:16 +0100 |
commit | 37d9916020286caec810f4de61fbd0de3568454d (patch) | |
tree | d9d80040f72093664d8a20b55de2a670988d281e /src/interfaces/libpq/pqexpbuffer.c | |
parent | cf40dc65b676c8df1ee12f060b40f0e37a183e04 (diff) |
More unconstify use
Replace casts whose only purpose is to cast away const with the
unconstify() macro.
Discussion: https://www.postgresql.org/message-id/flat/53a28052-f9f3-1808-fed9-460fd43035ab%402ndquadrant.com
Diffstat (limited to 'src/interfaces/libpq/pqexpbuffer.c')
-rw-r--r-- | src/interfaces/libpq/pqexpbuffer.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/interfaces/libpq/pqexpbuffer.c b/src/interfaces/libpq/pqexpbuffer.c index 498f82bd994..dc7c3ea07d4 100644 --- a/src/interfaces/libpq/pqexpbuffer.c +++ b/src/interfaces/libpq/pqexpbuffer.c @@ -36,6 +36,8 @@ /* All "broken" PQExpBuffers point to this string. */ static const char oom_buffer[1] = ""; +/* Need a char * for unconstify() compatiblity */ +static const char * oom_buffer_ptr = oom_buffer; static bool appendPQExpBufferVA(PQExpBuffer str, const char *fmt, va_list args) pg_attribute_printf(2, 0); @@ -57,7 +59,7 @@ markPQExpBufferBroken(PQExpBuffer str) * to put oom_buffer in read-only storage, so that anyone who tries to * scribble on a broken PQExpBuffer will get a failure. */ - str->data = (char *) oom_buffer; + str->data = unconstify(char *, oom_buffer_ptr); str->len = 0; str->maxlen = 0; } @@ -91,7 +93,7 @@ initPQExpBuffer(PQExpBuffer str) str->data = (char *) malloc(INITIAL_EXPBUFFER_SIZE); if (str->data == NULL) { - str->data = (char *) oom_buffer; /* see comment above */ + str->data = unconstify(char *, oom_buffer_ptr); /* see comment above */ str->maxlen = 0; str->len = 0; } @@ -130,7 +132,7 @@ termPQExpBuffer(PQExpBuffer str) if (str->data != oom_buffer) free(str->data); /* just for luck, make the buffer validly empty. */ - str->data = (char *) oom_buffer; /* see comment above */ + str->data = unconstify(char *, oom_buffer_ptr); /* see comment above */ str->maxlen = 0; str->len = 0; } |