Skip to content

Commit a95ec8e

Browse files
committed
Fix C++ operator new/delete signatures
Update the global C++ new/delete overrides to use `noexcept`, clean up parameter naming, and refresh the copyright headers.
1 parent 06486e2 commit a95ec8e

3 files changed

Lines changed: 12 additions & 12 deletions

File tree

lib-clib/src/c++/delete.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @file delete.cpp
33
*
44
*/
5-
/* Copyright (C) 2017-2025 by Arjan van Vught mailto:info@info@gd32-dmx.org
5+
/* Copyright (C) 2017-2026 by Arjan van Vught mailto:info@gd32-dmx.org
66
*
77
* Permission is hereby granted, free of charge, to any person obtaining a copy
88
* of this software and associated documentation files (the "Software"), to deal
@@ -31,25 +31,25 @@
3131
* These are the global operator delete overloads for single objects (delete) and arrays (delete[]).
3232
*/
3333

34-
void operator delete(void *p) {
35-
free(p);
34+
void operator delete(void *pointer) noexcept {
35+
free(pointer);
3636
}
3737

38-
void operator delete[](void *p) {
39-
free(p);
38+
void operator delete[](void *pointer) noexcept {
39+
free(pointer);
4040
}
4141

4242
/*
4343
* Introduced in C++14.
4444
* These overloads include the size of the object being deleted as an additional parameter (std::size_t size).
4545
*/
4646

47-
void operator delete(void *p, [[maybe_unused]] std::size_t size) noexcept {
48-
free(p);
47+
void operator delete(void *pointer, [[maybe_unused]] std::size_t size) noexcept {
48+
free(pointer);
4949
}
5050

51-
void operator delete[](void *p, [[maybe_unused]]std::size_t size) noexcept {
52-
free(p);
51+
void operator delete[](void *pointer, [[maybe_unused]]std::size_t size) noexcept {
52+
free(pointer);
5353
}
5454

5555
/*

lib-clib/src/c++/dso_handle.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @file dso_handle.cpp
33
*
44
*/
5-
/* Copyright (C) 2023 by Arjan van Vught mailto:info@info@gd32-dmx.org
5+
/* Copyright (C) 2023 by Arjan van Vught mailto:info@gd32-dmx.org
66
*
77
* Permission is hereby granted, free of charge, to any person obtaining a copy
88
* of this software and associated documentation files (the "Software"), to deal

lib-clib/src/c++/new.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @file new.cpp
33
*
44
*/
5-
/* Copyright (C) 2017-2025 by Arjan van Vught mailto:info@gd32-dmx.org
5+
/* Copyright (C) 2017-2026 by Arjan van Vught mailto:info@gd32-dmx.org
66
*
77
* Permission is hereby granted, free of charge, to any person obtaining a copy
88
* of this software and associated documentation files (the "Software"), to deal
@@ -49,6 +49,6 @@ void *operator new[](std::size_t size) {
4949
* Placement new does not allocate memory.
5050
*/
5151

52-
void *operator new([[maybe_unused]] std::size_t, void *ptr) noexcept {
52+
void *operator new([[maybe_unused]] std::size_t size, void *ptr) noexcept {
5353
return ptr;
5454
}

0 commit comments

Comments
 (0)