mariadb/storage/myisammrg
Nikita Malyavin 5d7f6f7e6e cleanup: replace thd->calloc<T>(N) with operator new T[N] {}
### Preamble

C++ initializes objects in three stages:
1. Optionally, zero-initializes the object fields.
2. Member-initializes fields that are explicitly set.
3. If applicable, calls a constructor.

The following expressions:
x = new T[N];
x = new T;
T x;

only member-initialize and call a default constructor. Stage 1 is skipped,
because () braces are omitted.

This is known as default-initialization.

Apart from Stage 2, the following:
x = new T[N]();
x = new T();
const T &x = T();

Is known as value-initialization:
If no default constructor is present, infer zero-initialization.
Otherwise, the default constructor is called.

Note that it's not possible to write `T x();`, as it is ambiguous to a function
call.

Since C++11, it's also possible to zero initialize objects with '{}' braces:
x = new T[N]{};
x = new T{};
T x{};

This also both zero-initializes and calls a default constructor.

There is no much difference in between empty-braced () and {}. Both call a
default constructor or initializer-list constructor, when available. Having both
constructors is ambiguous.

Scalars (i.e. fundamental data types) and POD types have no constructor.
Therefore, stage 2 for them is skipped.

Other than that, there is no much difference in the result

Exambles:
new char[123] -- would return an uninitialized array of char.
new char[123]() -- forces zero-initialization
new char[123]{} -- forces zero-initialization
new char[123]{123} -- forces zero-initialization, and also value-initializes
 the first element to 123

struct A {
  int x = 0xaf;
  int y;
}

All of the following:
A a;
A *a = new A;
A *a = new A[123];

Causes member A::x be initialized to 0xaf, since it happens at
value-initialization stage. A::y is left uninitialized.

A *a = new A[123] {};
and other similars result in {.x=0xaf, .y=0}.

### In this commit

Change all the calls to thd->calloc() to new(thd) T[N]{}, or new(thd) T{}.

POD types will be zero-initialized, so a special attention should be put to
classes with default constructors.

Among all uses, two cases of interest were found:
1. TABLE_LIST: has a default constructor TABLE_LIST() = default. This infers
zero-initialization behavior (i.e. as if there's no constructor).
2. USER_AUTH: has a default constructor, that initializes all fields. Strings
are initialized to "", which is fine.
3. Security_context: had a custom default constructor, initializing only two
fields. It was removed, and fields are made member-initialized.
2024-12-17 00:17:36 +01:00
..
mysql-test/storage_engine MDEV-32104 remove deprecated features 2023-09-30 14:43:12 +02:00
CMakeLists.txt Update FSF Address 2019-05-11 21:29:06 +03:00
ha_myisammrg.cc cleanup: replace thd->calloc<T>(N) with operator new T[N] {} 2024-12-17 00:17:36 +01:00
ha_myisammrg.h cleanup: key algorithm vs key flags 2024-11-05 14:00:47 -08:00
myrg_close.c Update FSF Address 2019-05-11 21:29:06 +03:00
myrg_create.c Merge branch '5.5' into 10.1 2019-05-11 22:19:05 +03:00
myrg_def.h perfschema memory related instrumentation changes 2020-03-10 19:24:22 +01:00
myrg_delete.c Update FSF Address 2019-05-11 21:29:06 +03:00
myrg_extra.c MDEV-18496 Crash when Aria encryption is enabled but plugin not available 2020-07-29 14:56:24 +02:00
myrg_info.c MDEV-28351: Assertion `this->file->children_attached' failed in ha_myisammrg::info 2023-08-11 19:36:22 +02:00
myrg_locking.c Update FSF Address 2019-05-11 21:29:06 +03:00
myrg_open.c MDEV-31083 ASAN use-after-poison in myrg_attach_children 2023-05-23 09:16:36 +03:00
myrg_panic.c Update FSF Address 2019-05-11 21:29:06 +03:00
myrg_queue.c MDEV-34348: Consolidate cmp function declarations 2024-11-23 08:14:22 -07:00
myrg_range.c Added page_range to records_in_range() to improve range statistics 2020-03-27 03:54:45 +02:00
myrg_records.c Update FSF Address 2019-05-11 21:29:06 +03:00
myrg_rfirst.c Update FSF Address 2019-05-11 21:29:06 +03:00
myrg_rkey.c Update FSF Address 2019-05-11 21:29:06 +03:00
myrg_rlast.c Update FSF Address 2019-05-11 21:29:06 +03:00
myrg_rnext.c Update FSF Address 2019-05-11 21:29:06 +03:00
myrg_rnext_same.c Update FSF Address 2019-05-11 21:29:06 +03:00
myrg_rprev.c Update FSF Address 2019-05-11 21:29:06 +03:00
myrg_rrnd.c Update FSF Address 2019-05-11 21:29:06 +03:00
myrg_rsame.c Update FSF Address 2019-05-11 21:29:06 +03:00
myrg_static.c cleanup: CREATE_TYPELIB_FOR() helper 2024-11-05 14:00:47 -08:00
myrg_update.c Merge 10.2 into 10.3 2019-05-14 17:18:46 +03:00
myrg_write.c MDEV-19955 make argument of handler::ha_write_row() const 2019-07-05 13:14:19 +03:00