summaryrefslogtreecommitdiff
path: root/src/glibext
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2017-07-12 22:47:38 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2017-07-12 22:47:38 (GMT)
commitd7f78fe9a75d96b6f3d441335dcf50a5c026d8ea (patch)
tree632744c467641825441b866c4f988c03d9c20cf1 /src/glibext
parentbdda063b67d8c1d402f6dc17726fed0c800d3d1c (diff)
Taken into account that raw immediate values can be used more than once.
Diffstat (limited to 'src/glibext')
-rw-r--r--src/glibext/gbuffercache.c31
1 files changed, 26 insertions, 5 deletions
diff --git a/src/glibext/gbuffercache.c b/src/glibext/gbuffercache.c
index fd7c987..f7dc49f 100644
--- a/src/glibext/gbuffercache.c
+++ b/src/glibext/gbuffercache.c
@@ -903,10 +903,15 @@ void g_buffer_cache_insert_at(GBufferCache *cache, size_t index, GLineGenerator
cache->lines = (cache_info *)realloc(cache->lines, cache->count * sizeof(cache_info));
}
}
-#ifndef NDEBUG
- else
- assert(needed == 1);
-#endif
+
+ else if (needed > 1)
+ {
+ if ((cache->used + needed - 1) >= cache->count)
+ {
+ cache->count += needed - 1 + LINE_ALLOC_BULK;
+ cache->lines = (cache_info *)realloc(cache->lines, cache->count * sizeof(cache_info));
+ }
+ }
/* Insertion du générateur */
@@ -934,7 +939,23 @@ void g_buffer_cache_insert_at(GBufferCache *cache, size_t index, GLineGenerator
g_width_tracker_update(cache->tracker, index);
- g_signal_emit_by_name(cache, "size-changed", true, index, 1);
+ if (needed > 1)
+ {
+ /* On déborde sur les lignes suivantes, donc on crée de l'espace ! */
+
+ memmove(&cache->lines[index + 1],
+ &cache->lines[index + 1 + needed - 1], (cache->used - index - 1) * sizeof(cache_info));
+
+ for (i = 1; i < needed; i++)
+ init_cache_info(&cache->lines[index + i], generator, i, BLF_NONE);
+
+ cache->used += needed - 1;
+
+ g_width_tracker_update_added(cache->tracker, index + 1, needed - 1);
+
+ }
+
+ g_signal_emit_by_name(cache, "size-changed", true, index, needed - 1);
}