Skip to content

Commit bc00715

Browse files
authored
CDRIVER-5617 remove building with BSON_MEMCHECK (#1921)
1 parent eec9b12 commit bc00715

File tree

4 files changed

+1
-55
lines changed

4 files changed

+1
-55
lines changed

src/libbson/NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ libbson 2.0.0 (Unreleased)
99
## Removals
1010

1111
* `bson_as_json` and `bson_array_as_json` are removed due to producing non-portable Legacy Extended JSON. Prefer Canonical Extended JSON or Relaxed Extended JSON for portability. To continue using Legacy Extended JSON, use `bson_as_legacy_extended_json` and `bson_array_as_legacy_extended_json`.
12+
* Compiling with `BSON_MEMCHECK` defined now has no effect.
1213

1314
libbson 1.30.2
1415
==============

src/libbson/src/bson/bson-private.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,13 @@ typedef enum {
4040
} bson_flags_t;
4141

4242

43-
#ifdef BSON_MEMCHECK
44-
#define BSON_INLINE_DATA_SIZE (120 - sizeof (char *))
45-
#else
4643
#define BSON_INLINE_DATA_SIZE 120
47-
#endif
4844

4945

5046
BSON_ALIGNED_BEGIN (128)
5147
typedef struct {
5248
bson_flags_t flags;
5349
uint32_t len;
54-
#ifdef BSON_MEMCHECK
55-
char *canary;
56-
#endif
5750
uint8_t data[BSON_INLINE_DATA_SIZE];
5851
} bson_impl_inline_t BSON_ALIGNED_END (128);
5952

src/libbson/src/bson/bson-types.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -120,20 +120,11 @@ typedef struct _bson_json_opts_t bson_json_opts_t;
120120
*
121121
* This structure is meant to fit in two sequential 64-byte cachelines.
122122
*/
123-
#ifdef BSON_MEMCHECK
124-
BSON_ALIGNED_BEGIN (128) typedef struct _bson_t {
125-
uint32_t flags; /* Internal flags for the bson_t. */
126-
uint32_t len; /* Length of BSON data. */
127-
char *canary; /* For leak checks. */
128-
uint8_t padding[120 - sizeof (char *)];
129-
} bson_t BSON_ALIGNED_END (128);
130-
#else
131123
BSON_ALIGNED_BEGIN (128) typedef struct _bson_t {
132124
uint32_t flags; /* Internal flags for the bson_t. */
133125
uint32_t len; /* Length of BSON data. */
134126
uint8_t padding[120]; /* Padding for stack allocation. */
135127
} bson_t BSON_ALIGNED_END (128);
136-
#endif
137128

138129
/**
139130
* BSON_INITIALIZER:
@@ -145,20 +136,13 @@ BSON_ALIGNED_BEGIN (128) typedef struct _bson_t {
145136
* bson_t b = BSON_INITIALIZER;
146137
* ]|
147138
*/
148-
#ifdef BSON_MEMCHECK
149-
#define BSON_INITIALIZER \
150-
{ \
151-
3, 5, bson_malloc (1), {5}, \
152-
}
153-
#else
154139
#define BSON_INITIALIZER \
155140
{ \
156141
3, 5, \
157142
{ \
158143
5 \
159144
} \
160145
}
161-
#endif
162146

163147

164148
BSON_STATIC_ASSERT2 (bson_t, sizeof (bson_t) == 128);

src/libbson/src/bson/bson.c

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,6 @@
2828
#include <string.h>
2929
#include <math.h>
3030

31-
#ifdef BSON_MEMCHECK
32-
#pragma message( \
33-
"Do not define BSON_MEMCHECK. BSON_MEMCHECK changes the data layout of bson_t. BSON_MEMCHECK is deprecated may be removed in a future major release")
34-
#endif
35-
3631

3732
typedef enum {
3833
BSON_VALIDATE_PHASE_START,
@@ -131,9 +126,6 @@ _bson_impl_inline_grow (bson_impl_inline_t *impl, /* IN */
131126
data = bson_malloc (req);
132127

133128
memcpy (data, impl->data, impl->len);
134-
#ifdef BSON_MEMCHECK
135-
bson_free (impl->canary);
136-
#endif
137129
alloc->flags &= ~BSON_FLAG_INLINE;
138130
alloc->parent = NULL;
139131
alloc->depth = 0;
@@ -1897,9 +1889,6 @@ bson_init (bson_t *bson)
18971889

18981890
BSON_ASSERT (bson);
18991891

1900-
#ifdef BSON_MEMCHECK
1901-
impl->canary = bson_malloc (1);
1902-
#endif
19031892
impl->flags = BSON_FLAG_INLINE | BSON_FLAG_STATIC;
19041893
impl->len = 5;
19051894
impl->data[0] = 5;
@@ -1978,9 +1967,6 @@ bson_new (void)
19781967
impl = (bson_impl_inline_t *) bson;
19791968
impl->flags = BSON_FLAG_INLINE;
19801969
impl->len = 5;
1981-
#ifdef BSON_MEMCHECK
1982-
impl->canary = bson_malloc (1);
1983-
#endif
19841970
impl->data[0] = 5;
19851971
impl->data[1] = 0;
19861972
impl->data[2] = 0;
@@ -2129,13 +2115,7 @@ bson_copy_to (const bson_t *src, bson_t *dst)
21292115
BSON_ASSERT (dst);
21302116

21312117
if ((src->flags & BSON_FLAG_INLINE)) {
2132-
#ifdef BSON_MEMCHECK
2133-
dst->len = src->len;
2134-
dst->canary = bson_malloc (1);
2135-
memcpy (dst->padding, src->padding, sizeof dst->padding);
2136-
#else
21372118
memcpy (dst, src, sizeof *dst);
2138-
#endif
21392119
dst->flags = (BSON_FLAG_STATIC | BSON_FLAG_INLINE);
21402120
return;
21412121
}
@@ -2245,12 +2225,6 @@ bson_destroy (bson_t *bson)
22452225
bson_free (*((bson_impl_alloc_t *) bson)->buf);
22462226
}
22472227

2248-
#ifdef BSON_MEMCHECK
2249-
if (bson->flags & BSON_FLAG_INLINE) {
2250-
bson_free (bson->canary);
2251-
}
2252-
#endif
2253-
22542228
if (!(bson->flags & BSON_FLAG_STATIC)) {
22552229
bson_free (bson);
22562230
}
@@ -2317,13 +2291,7 @@ bson_steal (bson_t *dst, bson_t *src)
23172291

23182292
/* for consistency, src is always invalid after steal, even if inline */
23192293
src->len = 0;
2320-
#ifdef BSON_MEMCHECK
2321-
bson_free (src->canary);
2322-
#endif
23232294
} else {
2324-
#ifdef BSON_MEMCHECK
2325-
bson_free (dst->canary);
2326-
#endif
23272295
memcpy (dst, src, sizeof (bson_t));
23282296
alloc = (bson_impl_alloc_t *) dst;
23292297
alloc->flags |= BSON_FLAG_STATIC;

0 commit comments

Comments
 (0)