Skip to content

Commit cc193f1

Browse files
committed
vcs-svn: allow character-oriented input
buffer_read_char can be used in place of buffer_read_string(1) to avoid consuming valuable static buffer space. The delta applier will use this to read variable-length integers one byte at a time. Underneath, it is fgetc, wrapped so the line_buffer library can maintain its role as gatekeeper of input. Later it might be worth checking if fgetc_unlocked is faster --- most line_buffer functions are not thread-safe anyway. Helpd-by: David Barr <[email protected]> Signed-off-by: Jonathan Nieder <[email protected]>
1 parent e832f43 commit cc193f1

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

vcs-svn/line_buffer.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ int buffer_deinit(struct line_buffer *buf)
2727
return err;
2828
}
2929

30+
int buffer_read_char(struct line_buffer *buf)
31+
{
32+
return fgetc(buf->infile);
33+
}
34+
3035
/* Read a line without trailing newline. */
3136
char *buffer_read_line(struct line_buffer *buf)
3237
{

vcs-svn/line_buffer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ int buffer_init(struct line_buffer *buf, const char *filename);
1616
int buffer_deinit(struct line_buffer *buf);
1717
char *buffer_read_line(struct line_buffer *buf);
1818
char *buffer_read_string(struct line_buffer *buf, uint32_t len);
19+
int buffer_read_char(struct line_buffer *buf);
1920
void buffer_read_binary(struct line_buffer *buf, struct strbuf *sb, uint32_t len);
2021
void buffer_copy_bytes(struct line_buffer *buf, uint32_t len);
2122
void buffer_skip_bytes(struct line_buffer *buf, uint32_t len);

0 commit comments

Comments
 (0)