Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Don't use buffer structs

  • Loading branch information...
commit 110b4f93ce04aef22c4095cf3da46b8bc439b20e 1 parent eefcec3
@mturk mturk authored
View
17 modules/ashiaro-common-native/src/main/native/include/acu/file.h
@@ -299,16 +299,20 @@ struct file_stream
#else
int _file; /**< cached os file_descriptor */
#endif
- iiobuf _bf; /**< the buffer (at least 1 byte, if !NULL) */
- int _lbfsize; /**< 0 or -_bf._size, for inline putc */
- /* separate buffer for long sequences of ungetc() */
- iiobuf _ub; /**< ungetc buffer */
byte *_up; /**< saved _p when _p is doing ungetc data */
+ byte *_bf_base; /**< the buffer (at least 1 byte, if !NULL) */
+ /* separate buffer for long sequences of ungetc() */
+ byte *_ub_base; /**< ungetc buffer */
+ /* separate buffer for fgetln() when line crosses buffer boundary */
+ byte *_lb_base; /**< buffer for fgetln() */
+ int _lbfsize; /**< 0 or -_bf._size, for inline putc */
+ int _bf_size;
+ int _ub_size;
+ int _lb_size;
+
/* tricks to meet minimum requirements even when malloc() fails */
byte _ubuf[3]; /**< guarantee an ungetc() buffer */
byte _nbuf[1]; /**< guarantee a getc() buffer */
- /* separate buffer for fgetln() when line crosses buffer boundary */
- iiobuf _lb; /**< buffer for fgetln() */
/* Unix stdio files get aligned to block boundaries on fseek() */
int _blksize; /**< stat.st_blksize (may be != _bf._size) */
int _timeout; /**< timeout in milliseconds */
@@ -316,7 +320,6 @@ struct file_stream
int _orientation; /**< orientation for fwide() */
acu_off_t _offset; /**< current lseek offset */
mutex *_mutex; /**< used for MT-safety */
- mbstate_t _mbstate; /**< multibyte conversion state */
/* Public low-level api */
/**
View
6 modules/ashiaro-common-native/src/main/native/include/acu/io.h
@@ -51,12 +51,6 @@ struct uiovec {
int uio_resid;
};
-struct iiobuf
-{
- byte *_base;
- int _size;
-};
-
class descriptor : public refcountable
{
public:
View
34 modules/ashiaro-common-native/src/main/native/shared/file.cc
@@ -133,12 +133,14 @@ file_stream *
file_stream_cache::acquire(bool mt_)
{
file_stream *fp = 0;
+ mutex *mp = 0;
scoped_thread_lock __g(_C_mutex);
if (mt_) {
if (!ACU_RING_EMPTY(&_F_cache.free_streams, file_stream, _link)) {
fp = ACU_RING_FIRST(&_F_cache.free_streams);
ACU_RING_REMOVE(fp, _link);
+ mp = fp->_mutex;
_F_free--;
}
}
@@ -146,45 +148,33 @@ file_stream_cache::acquire(bool mt_)
if (!ACU_RING_EMPTY(&_F_cache.dead_streams, file_stream, _link)) {
fp = ACU_RING_FIRST(&_F_cache.dead_streams);
ACU_RING_REMOVE(fp, _link);
+ mp = fp->_mutex;
_F_free--;
}
}
if (fp == 0) {
- fp = reinterpret_cast<file_stream *>(::calloc(1, sizeof(file_stream)));
+ fp = reinterpret_cast<file_stream *>(::malloc(sizeof(file_stream)));
if (fp == 0)
return 0;
- ACU_RING_ELEM_INIT(fp, _link);
}
- if (mt_ && fp->_mutex == 0) {
+ if (mt_ && mp == 0) {
try {
- fp->_mutex = new thread_mutex();
+ mp = new thread_mutex();
} catch (...) {
memory::free(fp);
ACU_SET_OS_ERROR(ACU_ENOMEM);
return 0;
}
}
+ ::memset(fp, 0, sizeofsizeof(file_stream));
#if defined(_WINDOWS)
fp->_ow.fp = fp;
fp->_fh = INVALID_HANDLE_VALUE;
#else
fp->_file = -1;
#endif
- fp->_p = 0; /* no current pointer */
- fp->_w = 0; /* nothing to read or write */
- fp->_r = 0;
- fp->_bf._base = 0; /* no buffer */
- fp->_bf._size = 0;
- fp->_lbfsize = 0; /* not line buffered */
- fp->_ub._base = 0; /* no ungetc buffer */
- fp->_ub._size = 0;
- fp->_lb._base = 0; /* no line buffer */
- fp->_lb._size = 0;
- fp->_blksize = 0;
- fp->_type = 0;
- fp->_offset = 0;
- fp->_timeout = 0;
-
+ fp->_mutex = mp;
+ ACU_RING_ELEM_INIT(fp, _link);
ACU_RING_INSERT_TAIL(&_F_cache.used_streams, fp, file_stream, _link);
return fp;
}
@@ -198,9 +188,9 @@ file_stream_cache::push_back(file_stream *fp)
SAFE_CLOSE_HANDLE(fp->_ow.overlap.hEvent);
#endif
/* Free line and ungetc buffers */
- if (fp->_ub._base != fp->_ubuf)
- memory::free(fp->_ub._base);
- memory::free(fp->_lb._base);
+ if (fp->_ub_base != fp->_ubuf)
+ memory::free(fp->_ub_base);
+ memory::free(fp->_lb_base);
scoped_thread_lock __g(_C_mutex);
ACU_RING_REMOVE(fp, _link);
View
36 modules/ashiaro-common-native/src/main/native/shared/fileioc.cc
@@ -21,22 +21,22 @@
* Test whether the given stdio file has an active ungetc buffer;
* release such a buffer, without restoring ordinary unread data.
*/
-#define HASUB(fp) ((fp)->_ub._base != 0)
+#define HASUB(fp) ((fp)->_ub_base != 0)
#define FREEUB(fp) \
{ \
- if ((fp)->_ub._base != (fp)->_ubuf) \
- ::free((fp)->_ub._base); \
- (fp)->_ub._base = 0; \
+ if ((fp)->_ub_base != (fp)->_ubuf) \
+ ::free((fp)->_ub_base); \
+ (fp)->_ub_base = 0; \
}
/*
* test for an fgetln() buffer.
*/
-#define HASLB(fp) ((fp)->_lb._base != 0)
+#define HASLB(fp) ((fp)->_lb_base != 0)
#define FREELB(fp) \
{ \
- ::free((fp)->_lb._base); \
- (fp)->_lb._base = 0; \
+ ::free((fp)->_lb_base); \
+ (fp)->_lb_base = 0; \
}
/*
@@ -104,7 +104,7 @@ __swsetup(file_stream *fp)
FREEUB(fp);
fp->_flags &= ~(__A_SRD|__A_SEOF);
fp->_r = 0;
- fp->_p = fp->_bf._base;
+ fp->_p = fp->_bf_base;
}
fp->_flags |= __A_SWR;
}
@@ -112,7 +112,7 @@ __swsetup(file_stream *fp)
/*
* Make a buffer if necessary, then set _w.
*/
- if (fp->_bf._base == 0)
+ if (fp->_bf_base == 0)
__smakebuf(fp);
if (fp->_flags & __A_SLBF) {
/*
@@ -121,13 +121,13 @@ __swsetup(file_stream *fp)
* to 0 whenever we turn off __SWR.
*/
fp->_w = 0;
- fp->_lbfsize = -fp->_bf._size;
+ fp->_lbfsize = -fp->_bf_size;
}
else {
if (fp->_flags & __A_SNBF)
fp->_w = 0;
else
- fp->_w = fp->_bf._size;
+ fp->_w = fp->_bf_size;
}
return 0;
}
@@ -140,7 +140,7 @@ static inline bool
__prepwrite(file_stream *fp)
{
if (((fp->_flags & __A_SWR) == 0 ||
- (fp->_bf._base == 0 &&
+ (fp->_bf_base == 0 &&
(fp->_flags & __A_SSTR) == 0)) && __swsetup(fp) != 0)
return true;
else
@@ -194,7 +194,7 @@ __srsetup(file_stream *fp)
}
}
- if (fp->_bf._base == 0)
+ if (fp->_bf_base == 0)
__smakebuf(fp);
/*
@@ -215,7 +215,7 @@ __srsetup(file_stream *fp)
if ((fp->_flags & (__A_SLBF|__A_SWR)) == (__A_SLBF|__A_SWR))
__sflush(fp);
}
- fp->_p = fp->_bf._base;
+ fp->_p = fp->_bf_base;
return 0;
}
@@ -268,12 +268,12 @@ __slbexpand(file_stream *fp, int newsize)
void *p;
newsize++;
- if (fp->_lb._size >= newsize)
+ if (fp->_lb_size >= newsize)
return 0;
- if ((p = ::realloc(fp->_lb._base, newsize)) == 0)
+ if ((p = ::realloc(fp->_lb_base, newsize)) == 0)
return -1;
- fp->_lb._base = reinterpret_cast<byte *>(p);
- fp->_lb._size = newsize;
+ fp->_lb_base = reinterpret_cast<byte *>(p);
+ fp->_lb_size = newsize;
return 0;
}
View
103 modules/ashiaro-common-native/src/main/native/shared/fileioi.cc
@@ -26,7 +26,7 @@ __sflush(file_stream *fp)
if ((t & __A_SWR) == 0)
return 0;
- if ((p = fp->_bf._base) == 0)
+ if ((p = fp->_bf_base) == 0)
return 0;
n = idistance(fp->_p, p); /* write this much */
@@ -35,7 +35,7 @@ __sflush(file_stream *fp)
* exchange buffering (via setvbuf) in user write function.
*/
fp->_p = p;
- fp->_w = t & (__A_SLBF|__A_SNBF) ? 0 : fp->_bf._size;
+ fp->_w = t & (__A_SLBF|__A_SNBF) ? 0 : fp->_bf_size;
for (; n > 0; n -= w, p += w) {
w = __swrite(fp, p, n);
@@ -77,7 +77,7 @@ __swrchr(file_stream *fp, int c)
byte b;
/*
* In case we cannot write, or longjmp takes us out early,
- * make sure _w is 0 (if fully- or un-buffered) or -_bf._size
+ * make sure _w is 0 (if fully- or un-buffered) or -_bf_size
* (if line buffered) so that we will get called again.
* If we did not do this, a sufficient number of putc()
* calls might wrap _w from negative to positive.
@@ -94,19 +94,19 @@ __swrchr(file_stream *fp, int c)
* stuff c into the buffer. If this causes the buffer to fill
* completely, or if c is '\n' and the file is line buffered,
* flush it (perhaps a second time). The second flush will always
- * happen on unbuffered streams, where _bf._size==1; fflush()
+ * happen on unbuffered streams, where _bf_size==1; fflush()
* guarantees that putc() will always call wbuf() by setting _w
* to 0, so we need not do anything else.
*/
- n = idistance(fp->_p, fp->_bf._base);
- if (n >= fp->_bf._size) {
+ n = idistance(fp->_p, fp->_bf_base);
+ if (n >= fp->_bf_size) {
if (__fflush(fp) != 0)
return -1;
n = 0;
}
fp->_w--;
*fp->_p++ = c;
- if (++n == fp->_bf._size || (fp->_flags & __A_SLBF && c == '\n')) {
+ if (++n == fp->_bf_size || (fp->_flags & __A_SLBF && c == '\n')) {
if (__fflush(fp) != 0)
return -1;
}
@@ -130,7 +130,7 @@ __srefill(file_stream *fp)
{
if (__srsetup(fp) != 0)
return -1;
- fp->_r = __sread(fp, fp->_p, fp->_bf._size);
+ fp->_r = __sread(fp, fp->_p, fp->_bf_size);
fp->_flags &= ~__A_SMOD; /* buffer contents are again pristine */
if (fp->_r <= 0) {
if (fp->_r == 0) {
@@ -272,7 +272,7 @@ __sfvwrite(file_stream *fp, uiovec *uio)
/*
* Fully buffered: fill partially full buffer, if any,
* and then flush. If there is no partial buffer, write
- * one _bf._size byte chunk directly (without copying).
+ * one _bf_size byte chunk directly (without copying).
*
* String output is a special case: write as many bytes
* as fit, but pretend we wrote everything. This makes
@@ -288,18 +288,18 @@ __sfvwrite(file_stream *fp, uiovec *uio)
iov++;
}
if ((fp->_flags & (__A_SALC | __A_SSTR)) == (__A_SALC | __A_SSTR) && fp->_w < len) {
- int blen = idistance(fp->_p, fp->_bf._base);
+ int blen = idistance(fp->_p, fp->_bf_base);
/*
* Alloc an extra 128 bytes (+ 1 for NULL)
* so we don't call realloc(3) so often.
*/
fp->_w = len + 128;
- fp->_bf._size = blen + len + 128;
- fp->_bf._base = reinterpret_cast<byte *>(::realloc(fp->_bf._base, fp->_bf._size + 1));
- if (fp->_bf._base == 0)
+ fp->_bf_size = blen + len + 128;
+ fp->_bf_base = reinterpret_cast<byte *>(::realloc(fp->_bf_base, fp->_bf_size + 1));
+ if (fp->_bf_base == 0)
goto err;
- fp->_p = fp->_bf._base + blen;
+ fp->_p = fp->_bf_base + blen;
}
w = fp->_w;
if (fp->_flags & __A_SSTR) {
@@ -312,7 +312,7 @@ __sfvwrite(file_stream *fp, uiovec *uio)
}
w = len; /* but pretend copied all */
}
- else if (fp->_p > fp->_bf._base && len > w) {
+ else if (fp->_p > fp->_bf_base && len > w) {
/* fill and flush */
::memcpy(fp->_p, p, w);
/* fp->_w -= w; */ /* unneeded */
@@ -320,7 +320,7 @@ __sfvwrite(file_stream *fp, uiovec *uio)
if (__fflush(fp) != 0)
goto err;
}
- else if (len >= (w = fp->_bf._size)) {
+ else if (len >= (w = fp->_bf_size)) {
/* write directly */
w = __swrite(fp, p, w);
if (w <= 0)
@@ -363,15 +363,15 @@ __sfvwrite(file_stream *fp, uiovec *uio)
nlknown = 1;
}
s = MIN(len, nldist);
- w = fp->_w + fp->_bf._size;
- if (fp->_p > fp->_bf._base && s > w) {
+ w = fp->_w + fp->_bf_size;
+ if (fp->_p > fp->_bf_base && s > w) {
::memcpy(fp->_p, p, w);
/* fp->_w -= w; */
fp->_p += w;
if (__fflush(fp) != 0)
goto err;
}
- else if (s >= (w = fp->_bf._size)) {
+ else if (s >= (w = fp->_bf_size)) {
w = __swrite(fp, p, w);
if (w <= 0)
goto err;
@@ -430,7 +430,7 @@ __sfwrite(file_stream *fp, const void *buf, int len)
/*
* Fully buffered: fill partially full buffer, if any,
* and then flush. If there is no partial buffer, write
- * one _bf._size byte chunk directly (without copying).
+ * one _bf_size byte chunk directly (without copying).
*
* String output is a special case: write as many bytes
* as fit, but pretend we wrote everything. This makes
@@ -440,18 +440,18 @@ __sfwrite(file_stream *fp, const void *buf, int len)
*/
do {
if ((fp->_flags & (__A_SALC | __A_SSTR)) == (__A_SALC | __A_SSTR) && fp->_w < len) {
- int blen = idistance(fp->_p, fp->_bf._base);
+ int blen = idistance(fp->_p, fp->_bf_base);
/*
* Alloc an extra 128 bytes (+ 1 for NULL)
* so we don't call realloc(3) so often.
*/
fp->_w = len + 128;
- fp->_bf._size = blen + len + 128;
- fp->_bf._base = reinterpret_cast<byte *>(::realloc(fp->_bf._base, fp->_bf._size + 1));
- if (fp->_bf._base == 0)
+ fp->_bf_size = blen + len + 128;
+ fp->_bf_base = reinterpret_cast<byte *>(::realloc(fp->_bf_base, fp->_bf_size + 1));
+ if (fp->_bf_base == 0)
goto err;
- fp->_p = fp->_bf._base + blen;
+ fp->_p = fp->_bf_base + blen;
}
w = fp->_w;
if (fp->_flags & __A_SSTR) {
@@ -464,7 +464,7 @@ __sfwrite(file_stream *fp, const void *buf, int len)
}
w = len; /* but pretend copied all */
}
- else if (fp->_p > fp->_bf._base && len > w) {
+ else if (fp->_p > fp->_bf_base && len > w) {
/* fill and flush */
::memcpy(fp->_p, p, w);
/* fp->_w -= w; */ /* unneeded */
@@ -472,7 +472,7 @@ __sfwrite(file_stream *fp, const void *buf, int len)
if (__fflush(fp) != 0)
goto err;
}
- else if (len >= (w = fp->_bf._size)) {
+ else if (len >= (w = fp->_bf_size)) {
/* write directly */
w = __swrite(fp, p, w);
if (w <= 0)
@@ -509,15 +509,15 @@ __sfwrite(file_stream *fp, const void *buf, int len)
nlknown = 1;
}
s = MIN(len, nldist);
- w = fp->_w + fp->_bf._size;
- if (fp->_p > fp->_bf._base && s > w) {
+ w = fp->_w + fp->_bf_size;
+ if (fp->_p > fp->_bf_base && s > w) {
::memcpy(fp->_p, p, w);
/* fp->_w -= w; */
fp->_p += w;
if (__fflush(fp) != 0)
goto err;
}
- else if (s >= (w = fp->_bf._size)) {
+ else if (s >= (w = fp->_bf_size)) {
w = __swrite(fp, p, w);
if (w <= 0)
goto err;
@@ -602,13 +602,13 @@ __fread(file_stream *fp, void *buf, size_t size)
resid -= r;
return total - resid;
}
- else if (fp->_bf._size != 0 && resid > fp->_bf._size) {
+ else if (fp->_bf_size != 0 && resid > fp->_bf_size) {
/* Optimized buffered read.
* We have a request for a read larger then buffer size.
* Read directly to user provided buffer without going
* trough our buffer.
*/
- n = resid - fp->_bf._size;
+ n = resid - fp->_bf_size;
r = __ubread(fp, p, n);
if (r == -1) {
/* Failed.
@@ -678,7 +678,7 @@ __ftello(file_stream *fp, acu_off_t *offset)
* position to be greater than that in the
* underlying object.
*/
- n = fp->_p - fp->_bf._base;
+ n = fp->_p - fp->_bf_base;
if (pos > static_cast<acu_off_t>(ACU_OFF_MAX - n)) {
ACU_SET_OS_ERROR(ACU_EOVERFLOW);
return -1;
@@ -753,7 +753,7 @@ __fseeko(file_stream *fp, acu_off_t offset, int whence)
* We must check __NBF first, because it is possible to have __NBF
* and __SOPT both set.
*/
- if (fp->_bf._base == 0)
+ if (fp->_bf_base == 0)
__smakebuf(fp);
if (fp->_flags & (__A_SWR | __A_SRW | __A_SNBF | __A_SNPT))
goto dumb;
@@ -805,12 +805,12 @@ __fseeko(file_stream *fp, acu_off_t offset, int whence)
*/
if (HASUB(fp)) {
curoff += fp->_r; /* kill off ungetc */
- n = idistance(fp->_up, fp->_bf._base);
+ n = idistance(fp->_up, fp->_bf_base);
curoff -= n;
n += fp->_ur;
}
else {
- n = idistance(fp->_p, fp->_bf._base);
+ n = idistance(fp->_p, fp->_bf_base);
curoff -= n;
n += fp->_r;
}
@@ -823,12 +823,11 @@ __fseeko(file_stream *fp, acu_off_t offset, int whence)
if (target >= curoff && target < curoff + n) {
int o = static_cast<int>(target - curoff);
- fp->_p = fp->_bf._base + o;
+ fp->_p = fp->_bf_base + o;
fp->_r = n - o;
if (HASUB(fp))
FREEUB(fp);
fp->_flags &= ~__A_SEOF;
- memset(&fp->_mbstate, 0, sizeof(mbstate_t));
return 0;
}
@@ -845,7 +844,7 @@ __fseeko(file_stream *fp, acu_off_t offset, int whence)
if (__sseek(fp, curoff, SEEK_SET) == POS_ERR)
goto dumb;
fp->_r = 0;
- fp->_p = fp->_bf._base;
+ fp->_p = fp->_bf_base;
if (HASUB(fp))
FREEUB(fp);
n = static_cast<int>(target - curoff);
@@ -856,12 +855,11 @@ __fseeko(file_stream *fp, acu_off_t offset, int whence)
fp->_r -= n;
}
fp->_flags &= ~__A_SEOF;
- memset(&fp->_mbstate, 0, sizeof(mbstate_t));
return 0;
/*
* We get here if we cannot optimise the seek ... just
- * do it. Allow the seek function to change fp->_bf._base.
+ * do it. Allow the seek function to change fp->_bf_base.
*/
dumb:
if (__sflush(fp) ||
@@ -870,11 +868,10 @@ __fseeko(file_stream *fp, acu_off_t offset, int whence)
/* success: clear EOF indicator and discard ungetc() data */
if (HASUB(fp))
FREEUB(fp);
- fp->_p = fp->_bf._base;
+ fp->_p = fp->_bf_base;
fp->_r = 0;
/* fp->_w = 0; */ /* unnecessary (I think...) */
fp->_flags &= ~__A_SEOF;
- memset(&fp->_mbstate, 0, sizeof(mbstate_t));
return 0;
}
@@ -940,13 +937,13 @@ __sgetln(file_stream *fp)
*/
if (__slbexpand(fp, len + OPTIMISTIC))
goto error;
- ::memcpy(fp->_lb._base + off, fp->_p, len - off);
+ ::memcpy(fp->_lb_base + off, fp->_p, len - off);
off = len;
if (__srefill(fp)) {
/* EOF or error.
* return partial line an ensure its NIL terminated
*/
- fp->_lb._base[len] = '\0';
+ fp->_lb_base[len] = '\0';
break;
}
if ((p = reinterpret_cast<byte *>(::memchr(fp->_p, '\n', fp->_r))) == 0)
@@ -963,12 +960,12 @@ __sgetln(file_stream *fp)
len += diff;
if (__slbexpand(fp, len))
goto error;
- ::memcpy(fp->_lb._base + off, fp->_p, diff);
+ ::memcpy(fp->_lb_base + off, fp->_p, diff);
fp->_r -= idistance(e, fp->_p);
fp->_p = e;
break;
}
- return reinterpret_cast<char *>(fp->_lb._base);
+ return reinterpret_cast<char *>(fp->_lb_base);
error:
return 0;
@@ -1083,7 +1080,7 @@ file_stream::setbuf(file_stream *fp, int mode, void *buf, int size)
fp->_r = fp->_lbfsize = 0;
flags = fp->_flags;
if (flags & __A_SMBF)
- ::free(fp->_bf._base);
+ ::free(fp->_bf_base);
flags &= ~(__A_SLBF | __A_SNBF | __A_SMBF | __A_SOPT | __A_SOFF | __A_SNPT | __A_SEOF);
/* If setting unbuffered mode, skip all the hard work. */
@@ -1119,8 +1116,8 @@ file_stream::setbuf(file_stream *fp, int mode, void *buf, int size)
nbf:
fp->_flags = flags | __A_SNBF;
fp->_w = 0;
- fp->_bf._base = fp->_p = fp->_nbuf;
- fp->_bf._size = 1;
+ fp->_bf_base = fp->_p = fp->_nbuf;
+ fp->_bf_size = 1;
_mt_file_leave(fp);
return ret;
}
@@ -1143,8 +1140,8 @@ file_stream::setbuf(file_stream *fp, int mode, void *buf, int size)
if (mode == _IOLBF)
flags |= __A_SLBF;
fp->_flags = flags;
- fp->_bf._base = fp->_p = reinterpret_cast<byte *>(buf);
- fp->_bf._size = size;
+ fp->_bf_base = fp->_p = reinterpret_cast<byte *>(buf);
+ fp->_bf_size = size;
/* fp->_lbfsize is still 0 */
if (flags & __A_SWR) {
/*
@@ -1153,7 +1150,7 @@ file_stream::setbuf(file_stream *fp, int mode, void *buf, int size)
*/
if (flags & __A_SLBF) {
fp->_w = 0;
- fp->_lbfsize = -fp->_bf._size;
+ fp->_lbfsize = -fp->_bf_size;
}
else {
fp->_w = size;
View
14 modules/ashiaro-common-native/src/main/native/unix/fileio.cc
@@ -270,20 +270,20 @@ __smakebuf(file_stream *fp)
int couldbetty;
if (fp->_flags & __A_SNBF) {
- fp->_bf._base = fp->_p = fp->_nbuf;
- fp->_bf._size = 1;
+ fp->_bf_base = fp->_p = fp->_nbuf;
+ fp->_bf_size = 1;
return;
}
flags = __swhatbuf(fp, &size, &couldbetty);
if ((p = ::malloc(size)) == 0) {
fp->_flags |= __A_SNBF;
- fp->_bf._base = fp->_p = fp->_nbuf;
- fp->_bf._size = 1;
+ fp->_bf_base = fp->_p = fp->_nbuf;
+ fp->_bf_size = 1;
return;
}
flags |= __A_SMBF;
- fp->_bf._base = fp->_p = reinterpret_cast<byte *>(p);
- fp->_bf._size = size;
+ fp->_bf_base = fp->_p = reinterpret_cast<byte *>(p);
+ fp->_bf_size = size;
if (couldbetty && ::isatty(fp->_file))
flags |= __A_SLBF;
fp->_flags |= flags;
@@ -430,7 +430,7 @@ file_stream::close(file_stream *fp)
else
r = restartable_close(fd);
if (ff & __A_SMBF)
- ::free(fp->_bf._base);
+ ::free(fp->_bf_base);
_mt_file_leave(fp);
if (ff & __A_SMTX)
View
14 modules/ashiaro-common-native/src/main/native/win32/fileio.cc
@@ -447,20 +447,20 @@ __smakebuf(file_stream *fp)
int couldbetty;
if (fp->_flags & __A_SNBF) {
- fp->_bf._base = fp->_p = fp->_nbuf;
- fp->_bf._size = 1;
+ fp->_bf_base = fp->_p = fp->_nbuf;
+ fp->_bf_size = 1;
return;
}
flags = __swhatbuf(fp, &size, &couldbetty);
if ((p = ::malloc(size)) == 0) {
fp->_flags |= __A_SNBF;
- fp->_bf._base = fp->_p = fp->_nbuf;
- fp->_bf._size = 1;
+ fp->_bf_base = fp->_p = fp->_nbuf;
+ fp->_bf_size = 1;
return;
}
flags |= __A_SMBF;
- fp->_bf._base = fp->_p = reinterpret_cast<byte *>(p);
- fp->_bf._size = size;
+ fp->_bf_base = fp->_p = reinterpret_cast<byte *>(p);
+ fp->_bf_size = size;
if (couldbetty)
flags |= __A_SLBF;
fp->_flags |= flags;
@@ -646,7 +646,7 @@ file_stream::close(file_stream *fp)
}
SAFE_CLOSE_HANDLE(fp->_ow.overlap.hEvent);
if (ff & __A_SMBF)
- ::free(fp->_bf._base);
+ ::free(fp->_bf_base);
_mt_file_leave(fp);
if (ff & __A_SMTX)
Please sign in to comment.
Something went wrong with that request. Please try again.