Skip to content

More new used instead of malloc(). Code reorganization.#76

Merged
agruzdev merged 7 commits intoagruzdev:masterfrom
lordnn:master
May 3, 2026
Merged

More new used instead of malloc(). Code reorganization.#76
agruzdev merged 7 commits intoagruzdev:masterfrom
lordnn:master

Conversation

@lordnn
Copy link
Copy Markdown
Contributor

@lordnn lordnn commented Apr 25, 2026

No description provided.

@lordnn lordnn changed the title More new used instead of malloc(). Code reorganization, More new used instead of malloc(). Code reorganization. Apr 25, 2026
template <> struct ToUnsignedTypeImpl<int8_t> { using type = uint8_t; };

template <typename Ty_>
using ToUnsignedType = typename ToUnsignedTypeImpl<Ty_>::type;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А зачем вы упаковали эти шаблоны по cpp файлам? Многие из них достаточно универсальные, могут понадобится в других файлах... Чтобы быстрее компилировалось, пока не понадобилось?

Copy link
Copy Markdown
Contributor Author

@lordnn lordnn May 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Именно! Пока нет доказательств, что они нужны где-то ещё, пускай живут в CPP, решил я.

Comment thread Source/Plugins/J2KHelper.cpp Outdated
return nullptr;
}
auto *fio = (J2KFIO_t*)malloc(sizeof(J2KFIO_t));
auto fio{ std::make_unique<J2KFIO_t>() };
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

может быть тоже nothrow?

Copy link
Copy Markdown
Contributor Author

@lordnn lordnn May 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Согласен. (6fa3c8d)

Comment thread Source/Plugins/PluginICO.cpp Outdated
Open(FreeImageIO *io, fi_handle handle, FIBOOL read) {
// Allocate memory for the header structure
auto *lpIH = (ICONHEADER*)malloc(sizeof(ICONHEADER));
std::unique_ptr<ICONHEADER, decltype(&free)> lpIH(static_cast<ICONHEADER*>(malloc(sizeof(ICONHEADER))), &free);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а почему malloc?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Потому что этот указатель возвращается из функции и надо тогда искать править в месте удаления.

Copy link
Copy Markdown
Contributor Author

@lordnn lordnn May 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Но, попробовать можно... (e0dd6eb)

unsigned cbStrideFrom = ((pPIFrom.cbitUnit + 7) >> 3) * width;
unsigned cbStrideTo = ((pPITo.cbitUnit + 7) >> 3) * width;
cbStride = MAX(cbStrideFrom, cbStrideTo);
cbStride = (std::max)(cbStrideFrom, cbStrideTo);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а зачем здесь скобки?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В недрах JXR-заголовков есть #define max(... без скобок он тут применяется и std:: оказывается синтаксической ошибкой.

@agruzdev agruzdev merged commit a96ed98 into agruzdev:master May 3, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants