Skip to content

Commit e0e0b2f

Browse files
committed
Simplify pword storage
1 parent d6fdb7f commit e0e0b2f

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

core/src/dataio.cxx

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -476,14 +476,13 @@ g3_istream_from_path(std::istream &stream, const std::string &path, float timeou
476476

477477
stream.rdbuf(sbuf);
478478
stream.pword(0) = file;
479-
stream.pword(1) = sbuf;
480-
stream.pword(2) = fbuf;
479+
stream.pword(1) = fbuf;
481480
}
482481

483482
int
484483
g3_istream_handle(std::istream &stream)
485484
{
486-
std::streambuf* sbuf = static_cast<std::streambuf*>(stream.pword(1));
485+
std::streambuf* sbuf = stream.rdbuf();
487486
if (!sbuf)
488487
return -1;
489488
RemoteInputStreamBuffer* rbuf = dynamic_cast<RemoteInputStreamBuffer*>(sbuf);
@@ -495,22 +494,19 @@ g3_istream_handle(std::istream &stream)
495494
void
496495
g3_istream_close(std::istream &stream)
497496
{
498-
std::ifstream* file = static_cast<std::ifstream*>(stream.pword(0));
499-
std::streambuf* sbuf = static_cast<std::streambuf*>(stream.pword(1));
500-
std::vector<char>* fbuf = static_cast<std::vector<char>*>(stream.pword(2));
501-
497+
std::vector<char>* fbuf = static_cast<std::vector<char>*>(stream.pword(1));
502498
if (fbuf)
503499
delete fbuf;
504-
stream.pword(2) = nullptr;
505-
506-
if (sbuf)
507-
delete sbuf;
508500
stream.pword(1) = nullptr;
509501

502+
std::ifstream* file = static_cast<std::ifstream*>(stream.pword(0));
510503
if (file)
511504
delete file;
512505
stream.pword(0) = nullptr;
513506

507+
std::streambuf* sbuf = stream.rdbuf();
508+
if (sbuf)
509+
delete sbuf;
514510
stream.rdbuf(nullptr);
515511
}
516512

@@ -736,7 +732,6 @@ g3_ostream_to_path(std::ostream &stream, const std::string &path, bool append,
736732

737733
stream.rdbuf(sbuf);
738734
stream.pword(0) = file;
739-
stream.pword(1) = sbuf;
740735
}
741736

742737
void
@@ -763,11 +758,9 @@ g3_ostream_close(std::ostream &stream)
763758
delete file;
764759
stream.pword(0) = nullptr;
765760

766-
std::streambuf* sbuf = static_cast<std::streambuf*>(stream.pword(1));
761+
std::streambuf* sbuf = stream.rdbuf();
767762
if (sbuf)
768763
delete sbuf;
769-
stream.pword(1) = nullptr;
770-
771764
stream.rdbuf(nullptr);
772765
}
773766

0 commit comments

Comments
 (0)