summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@behdad.org>2009-09-15 21:22:53 -0400
committerBehdad Esfahbod <behdad@behdad.org>2009-09-15 21:26:43 -0400
commit109f77b663e4f87e4fb148ae26cd7a566de0cb61 (patch)
treec25c039d931c0889e6252d0d5c7f8c5f040f1c14 /src
parent5254710eb86008ab218f2ad0a61e631f3f6d6b39 (diff)
[ring] Simplify a bit
Diffstat (limited to 'src')
-rw-r--r--src/ring.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/ring.c b/src/ring.c
index c4a2376..11ccd99 100644
--- a/src/ring.c
+++ b/src/ring.c
@@ -98,6 +98,18 @@ typedef struct _VteRowRecord {
gsize attr_offset;
} VteRowRecord;
+static gboolean
+_vte_ring_read_row_record (VteRing *ring, VteRowRecord *record, guint position)
+{
+ return _vte_stream_read (ring->row_stream, position * sizeof (*record), (char *) record, sizeof (*record));
+}
+
+static void
+_vte_ring_append_row_record (VteRing *ring, const VteRowRecord *record, guint position)
+{
+ _vte_stream_append (ring->row_stream, (const char *) record, sizeof (*record));
+}
+
static void
_vte_ring_freeze_row (VteRing *ring, guint position, const VteRowData *row)
{
@@ -159,7 +171,7 @@ _vte_ring_freeze_row (VteRing *ring, guint position, const VteRowData *row)
g_string_append_c (buffer, '\n');
_vte_stream_append (ring->text_stream, buffer->str, buffer->len);
- _vte_stream_append (ring->row_stream, (const char *) &record, sizeof (record));
+ _vte_ring_append_row_record (ring, &record, position);
}
static void
@@ -179,10 +191,10 @@ _vte_ring_thaw_row (VteRing *ring, guint position, VteRowData *row, gboolean tru
attr_change.text_offset = 0;
- if (!_vte_stream_read (ring->row_stream, position * sizeof (records[0]), (char *) &records[0], sizeof (records[0])))
+ if (!_vte_ring_read_row_record (ring, &records[0], position))
return;
- if ((position + 1) * sizeof (VteRowRecord) < _vte_stream_head (ring->row_stream)) {
- if (!_vte_stream_read (ring->row_stream, (position + 1) * sizeof (records[1]), (char *) &records[1], sizeof (records[1])))
+ if ((position + 1) * sizeof (records[0]) < _vte_stream_head (ring->row_stream)) {
+ if (!_vte_ring_read_row_record (ring, &records[1], position + 1))
return;
} else
records[1].text_offset = _vte_stream_head (ring->text_stream);