Skip to content

Commit

Permalink
Merge pull request #54 from svigerske/master
Browse files Browse the repository at this point in the history
eliminate use of std::make_unique, remove zstr_make_unique_polyfill.h

So that codebase does not mix GPL and MIT licenses, but is still C++11-compatible
  • Loading branch information
ferdymercury committed Apr 1, 2022
2 parents c73b8b4 + 12e18ea commit 7a94c2a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 96 deletions.
16 changes: 6 additions & 10 deletions src/zstr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
#include <memory>
#include <iostream>

#if __cplusplus == 201103L
#include <zstr_make_unique_polyfill.h>
#endif

namespace zstr
{

Expand Down Expand Up @@ -140,10 +136,10 @@ class istreambuf
window_bits(_window_bits)
{
assert(sbuf_p);
in_buff = std::make_unique<char[]>(buff_size);
in_buff = std::unique_ptr<char[]>(new char[buff_size]);
in_buff_start = in_buff.get();
in_buff_end = in_buff.get();
out_buff = std::make_unique<char[]>(buff_size);
out_buff = std::unique_ptr<char[]>(new char[buff_size]);
setg(out_buff.get(), out_buff.get(), out_buff.get());
}

Expand Down Expand Up @@ -213,7 +209,7 @@ class istreambuf
else
{
// run inflate() on input
if (! zstrm_p) zstrm_p = std::make_unique<detail::z_stream_wrapper>(true, Z_DEFAULT_COMPRESSION, window_bits);
if (! zstrm_p) zstrm_p = std::unique_ptr<detail::z_stream_wrapper>(new detail::z_stream_wrapper(true, Z_DEFAULT_COMPRESSION, window_bits));
zstrm_p->next_in = reinterpret_cast< decltype(zstrm_p->next_in) >(in_buff_start);
zstrm_p->avail_in = uint32_t(in_buff_end - in_buff_start);
zstrm_p->next_out = reinterpret_cast< decltype(zstrm_p->next_out) >(out_buff_free_start);
Expand Down Expand Up @@ -266,12 +262,12 @@ class ostreambuf
: sbuf_p(_sbuf_p),
in_buff(),
out_buff(),
zstrm_p(std::make_unique<detail::z_stream_wrapper>(false, _level, _window_bits)),
zstrm_p(new detail::z_stream_wrapper(false, _level, _window_bits)),
buff_size(_buff_size)
{
assert(sbuf_p);
in_buff = std::make_unique<char[]>(buff_size);
out_buff = std::make_unique<char[]>(buff_size);
in_buff = std::unique_ptr<char[]>(new char[buff_size]);
out_buff = std::unique_ptr<char[]>(new char[buff_size]);
setp(in_buff.get(), in_buff.get() + buff_size);
}

Expand Down
86 changes: 0 additions & 86 deletions src/zstr_make_unique_polyfill.h

This file was deleted.

0 comments on commit 7a94c2a

Please sign in to comment.