As of 2.23 the glibc seems to have changed its behavior on an fflush of a stream created with fmemopen, in that it resets the position to 0. I saw in the change-log that a the implementation of fmemopen was updated to fix a bunch of bugs, but none of those bugs talk about this behavior, and to me it seems like an incorrect change. I've been trying to determine if this a new bug, or a correct fix. My own code relies on the old behavior and broke after I updated to Ubuntu 16.04 which comes with glibc 2.23. Anybody know anything about this?
从2.23开始,glibc似乎改变了它在fmemopen创建的流的fflush上的行为,因为它将位置重置为0.我在change-log中看到fmemopen的实现被更新以修复一堆错误,但没有这些错误谈论这种行为,对我来说,这似乎是一个不正确的变化。我一直在试图确定这是一个新的错误,还是一个正确的修复。我自己的代码依赖于旧的行为,并在我更新到带有glibc 2.23的Ubuntu 16.04之后破了。有人对此有所了解吗?
Here's some sample code:
这是一些示例代码:
char buffer[500] = "x";
FILE *stream;
stream = fmemopen(buffer, 500, "r+");
fwrite("fish",sizeof(char),5,stream);
printf("pos-1:%ld\n",ftell(stream));
fflush(stream);
printf("pos-2:%ld\n",ftell(stream));
On earlier versions (e.g. under ubuntu 5.10<) this would result in:
在早期版本(例如在ubuntu 5.10 <下),这将导致:< p>
pos-1:5
pos-2:5
Now it returns:
现在它返回:
pos-1:5
pos-2:0
1 个解决方案
#1
3
It turns out to be a bug in 2.23. The bug was logged and has been fixed.
事实证明这是2.23中的一个错误。该错误已被记录并已修复。
#1
3
It turns out to be a bug in 2.23. The bug was logged and has been fixed.
事实证明这是2.23中的一个错误。该错误已被记录并已修复。