summaryrefslogtreecommitdiffstats
path: root/stream
diff options
context:
space:
mode:
authorreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2010-02-28 13:54:55 +0000
committerreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2010-02-28 13:54:55 +0000
commitc89169f7b5c13961a3183d3a8736b8558b2a0922 (patch)
treefd57fbda721e3d2bdfad907a2560d7aebbb0a7fa /stream
parentd8c02c2dd229b2fda576e0aa09cee4e0a6090b7b (diff)
downloadmpv-c89169f7b5c13961a3183d3a8736b8558b2a0922.tar.bz2
mpv-c89169f7b5c13961a3183d3a8736b8558b2a0922.tar.xz
Move stream_read_line implementation from stream.h to stream.c,
it is not speed critical and the function call overhead is not relevant for its overall speed anyway. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30796 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'stream')
-rw-r--r--stream/stream.c26
-rw-r--r--stream/stream.h27
2 files changed, 27 insertions, 26 deletions
diff --git a/stream/stream.c b/stream/stream.c
index daecc09d2c..47d4b9e2a5 100644
--- a/stream/stream.c
+++ b/stream/stream.c
@@ -487,3 +487,29 @@ int stream_check_interrupt(int time) {
if(!stream_check_interrupt_cb) return 0;
return stream_check_interrupt_cb(time);
}
+
+unsigned char* stream_read_line(stream_t *s,unsigned char* mem, int max) {
+ int len;
+ unsigned char* end,*ptr = mem;
+ if (max < 1) return NULL;
+ max--; // reserve one for 0-termination
+ do {
+ len = s->buf_len-s->buf_pos;
+ // try to fill the buffer
+ if(len <= 0 &&
+ (!cache_stream_fill_buffer(s) ||
+ (len = s->buf_len-s->buf_pos) <= 0)) break;
+ end = (unsigned char*) memchr((void*)(s->buffer+s->buf_pos),'\n',len);
+ if(end) len = end - (s->buffer+s->buf_pos) + 1;
+ if(len > 0 && max > 0) {
+ int l = len > max ? max : len;
+ memcpy(ptr,s->buffer+s->buf_pos,l);
+ max -= l;
+ ptr += l;
+ }
+ s->buf_pos += len;
+ } while(!end);
+ if(s->eof && ptr == mem) return NULL;
+ ptr[0] = 0;
+ return mem;
+}
diff --git a/stream/stream.h b/stream/stream.h
index 579468114a..cc70c81db5 100644
--- a/stream/stream.h
+++ b/stream/stream.h
@@ -265,32 +265,7 @@ inline static int stream_read(stream_t *s,char* mem,int total){
return total;
}
-inline static unsigned char* stream_read_line(stream_t *s,unsigned char* mem, int max) {
- int len;
- unsigned char* end,*ptr = mem;
- if (max < 1) return NULL;
- max--; // reserve one for 0-termination
- do {
- len = s->buf_len-s->buf_pos;
- // try to fill the buffer
- if(len <= 0 &&
- (!cache_stream_fill_buffer(s) ||
- (len = s->buf_len-s->buf_pos) <= 0)) break;
- end = (unsigned char*) memchr((void*)(s->buffer+s->buf_pos),'\n',len);
- if(end) len = end - (s->buffer+s->buf_pos) + 1;
- if(len > 0 && max > 0) {
- int l = len > max ? max : len;
- memcpy(ptr,s->buffer+s->buf_pos,l);
- max -= l;
- ptr += l;
- }
- s->buf_pos += len;
- } while(!end);
- if(s->eof && ptr == mem) return NULL;
- ptr[0] = 0;
- return mem;
-}
-
+unsigned char* stream_read_line(stream_t *s,unsigned char* mem, int max);
inline static int stream_eof(stream_t *s){
return s->eof;