summaryrefslogtreecommitdiff
path: root/src/glibext
diff options
context:
space:
mode:
Diffstat (limited to 'src/glibext')
-rw-r--r--src/glibext/buffercache.c38
1 files changed, 13 insertions, 25 deletions
diff --git a/src/glibext/buffercache.c b/src/glibext/buffercache.c
index ebe8a7f..fd2adc5 100644
--- a/src/glibext/buffercache.c
+++ b/src/glibext/buffercache.c
@@ -181,7 +181,7 @@ static void extend_cache_info(cache_info *info, GLineGenerator *generator, Buffe
{
first = info->generator;
- info->generators = (generator_link *)calloc(2, sizeof(generator_link));
+ info->generators = calloc(2, sizeof(generator_link));
info->generators[0] = first;
info->count = 2;
@@ -191,8 +191,7 @@ static void extend_cache_info(cache_info *info, GLineGenerator *generator, Buffe
}
else
{
- info->generators = (generator_link *)realloc(info->generators,
- ++info->count * sizeof(generator_link));
+ info->generators = realloc(info->generators, ++info->count * sizeof(generator_link));
new = &info->generators[info->count - 1];
@@ -273,8 +272,7 @@ static void remove_from_cache_info(cache_info *info, GLineGenerator *generator)
}
else
- info->generators = (generator_link *)realloc(info->generators,
- --info->count * sizeof(generator_link));
+ info->generators = realloc(info->generators, --info->count * sizeof(generator_link));
g_object_unref(G_OBJECT(generator));
@@ -956,7 +954,7 @@ void g_buffer_cache_insert_at(GBufferCache *cache, size_t index, GLineGenerator
if ((cache->used + needed) >= cache->count)
{
cache->count += needed + LINE_ALLOC_BULK;
- cache->lines = (cache_info *)realloc(cache->lines, cache->count * sizeof(cache_info));
+ cache->lines = realloc(cache->lines, cache->count * sizeof(cache_info));
}
}
@@ -965,7 +963,7 @@ void g_buffer_cache_insert_at(GBufferCache *cache, size_t index, GLineGenerator
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));
+ cache->lines = realloc(cache->lines, cache->count * sizeof(cache_info));
}
}
@@ -1207,6 +1205,7 @@ void g_buffer_cache_append(GBufferCache *cache, GLineGenerator *generator, Buffe
size_t index; /* Point d'insertion */
size_t i; /* Boucle de parcours */
cache_info *info; /* Accès direct à une ligne */
+ size_t repeat; /* Compteur de répétition */
assert(!g_rw_lock_writer_trylock(&cache->access));
@@ -1219,7 +1218,7 @@ void g_buffer_cache_append(GBufferCache *cache, GLineGenerator *generator, Buffe
if ((cache->used + count) > cache->count)
{
cache->count += count + LINE_ALLOC_BULK;
- cache->lines = (cache_info *)realloc(cache->lines, cache->count * sizeof(cache_info));
+ cache->lines = realloc(cache->lines, cache->count * sizeof(cache_info));
}
index = cache->used;
@@ -1228,16 +1227,9 @@ void g_buffer_cache_append(GBufferCache *cache, GLineGenerator *generator, Buffe
{
info = &cache->lines[index + i];
- info->generator.instance = generator;
- info->generator.repeat = g_buffer_cache_compute_repetition(cache, index + i, generator);
+ repeat = g_buffer_cache_compute_repetition(cache, index + i, generator);
- g_object_ref(G_OBJECT(generator));
-
- info->count = 1;
-
- info->line = NULL;
-
- info->extra_flags = flags;
+ init_cache_info(info, generator, repeat, flags);
}
@@ -1269,6 +1261,7 @@ void g_buffer_cache_extend_with(GBufferCache *cache, size_t count, GLineGenerato
size_t index; /* Point d'insertion */
size_t i; /* Boucle de parcours */
cache_info *info; /* Accès direct à une ligne */
+ size_t repeat; /* Compteur de répétition */
size_t added; /* Nombre d'ajouts effectués */
assert(!g_rw_lock_writer_trylock(&cache->access));
@@ -1277,7 +1270,7 @@ void g_buffer_cache_extend_with(GBufferCache *cache, size_t count, GLineGenerato
if (count > cache->count)
{
- cache->lines = (cache_info *)realloc(cache->lines, count * sizeof(cache_info));
+ cache->lines = realloc(cache->lines, count * sizeof(cache_info));
cache->count = count;
}
@@ -1287,14 +1280,9 @@ void g_buffer_cache_extend_with(GBufferCache *cache, size_t count, GLineGenerato
{
info = &cache->lines[i];
- info->generator.instance = generator;
- info->generator.repeat = g_buffer_cache_compute_repetition(cache, i, generator);
+ repeat = g_buffer_cache_compute_repetition(cache, i, generator);
- g_object_ref(G_OBJECT(generator));
-
- info->count = 1;
-
- info->line = NULL;
+ init_cache_info(info, generator, repeat, BLF_NONE);
}