aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2009-01-05 14:31:36 +0100
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2009-01-05 14:31:36 +0100
commit53eb3f779cb9cdb324745b889936db49808534fc (patch)
treef789327c8220aeeb82afade66c45bbcd423a013d
parent94095bbd0601de0c9cbea8897b89d7cbc453d4d1 (diff)
parentcb79d2d228695b68780eb3e90739cb7f99726c5a (diff)
merge
-rw-r--r--src/cache.c5
-rw-r--r--src/dicache.c10
-rw-r--r--src/gif.c1
-rw-r--r--src/jpeg.c1
-rw-r--r--src/png.c1
5 files changed, 13 insertions, 5 deletions
diff --git a/src/cache.c b/src/cache.c
index c1bdcec1..e9a3418e 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -425,6 +425,7 @@ static void Cache_ref_data(CacheEntry_t *entry)
entry->DataRefcount++;
_MSG("DataRefcount++: %d\n", entry->DataRefcount);
if (entry->CharsetDecoder && entry->DataRefcount == 1) {
+ dStr_free(entry->UTF8Data, 1);
entry->UTF8Data = a_Decode_process(entry->CharsetDecoder,
entry->Data->str,
entry->Data->len);
@@ -760,8 +761,10 @@ static void Cache_parse_header(CacheEntry_t *entry)
a_Misc_parse_content_type(Type, NULL, NULL, &charset);
if (charset) {
entry->CharsetDecoder = a_Decode_charset_init(charset);
- if (entry->CharsetDecoder)
+ if (entry->CharsetDecoder) {
+ dStr_free(entry->UTF8Data, 1);
entry->UTF8Data = dStr_new("");
+ }
dFree(charset);
}
}
diff --git a/src/dicache.c b/src/dicache.c
index 88a35daf..1c546e98 100644
--- a/src/dicache.c
+++ b/src/dicache.c
@@ -356,7 +356,7 @@ void a_Dicache_close(DilloUrl *url, int version, CacheClient_t *Client)
dReturn_if_fail ( DicEntry != NULL );
- /* print msg before actual unref to avoid dereferencing an invalid pointer */
+ /* a_Dicache_unref() may free DicEntry */
MSG("a_Dicache_close RefCount=%d\n", DicEntry->RefCount - 1);
if (DicEntry->State < DIC_Close) {
@@ -390,10 +390,12 @@ void a_Dicache_callback(int Op, CacheClient_t *Client)
Client->Version = DicEntry->version;
/* Only call the decoder when necessary */
+ int newData = FALSE;
if (Op == CA_Send && DicEntry->State < DIC_Close &&
DicEntry->DecodedSize < Client->BufSize) {
DicEntry->Decoder(Op, Client);
DicEntry->DecodedSize = Client->BufSize;
+ newData = TRUE;
} else if (Op == CA_Close || Op == CA_Abort) {
if (DicEntry->State < DIC_Close) {
DicEntry->Decoder(Op, Client);
@@ -411,7 +413,7 @@ void a_Dicache_callback(int Op, CacheClient_t *Client)
DicEntry->version, DicEntry->width, DicEntry->height,
DicEntry->type);
}
- if (DicEntry->State == DIC_Write) {
+ if (DicEntry->State == DIC_Write && newData) {
if (DicEntry->ScanNumber == Image->ScanNumber) {
for (i = 0; i < DicEntry->height; ++i)
if (a_Bitvec_get_bit(DicEntry->BitVec, (int)i) &&
@@ -452,8 +454,8 @@ void a_Dicache_cleanup(void)
node = dList_nth_data(CachedIMGs, i);
/* iterate each entry of this node */
for (entry = node->first; entry; entry = entry->next) {
- if (entry->v_imgbuf &&
- a_Imgbuf_last_reference(entry->v_imgbuf)) {
+ if (entry->RefCount == 1 ||
+ (entry->v_imgbuf && a_Imgbuf_last_reference(entry->v_imgbuf))) {
/* free this unused entry */
if (entry->next) {
Dicache_remove(node->url, entry->version);
diff --git a/src/gif.c b/src/gif.c
index ea6990b3..af1a3842 100644
--- a/src/gif.c
+++ b/src/gif.c
@@ -179,6 +179,7 @@ void *a_Gif_image(const char *Type, void *Ptr, CA_Callback_t *Call,
DicEntry = a_Dicache_add_entry(web->url);
DicEntry->DecoderData =
Gif_new(web->Image, DicEntry->url, DicEntry->version);
+ a_Dicache_ref(DicEntry->url, DicEntry->version);
} else {
/* Repeated image */
a_Dicache_ref(DicEntry->url, DicEntry->version);
diff --git a/src/jpeg.c b/src/jpeg.c
index 4da2d39e..97254da4 100644
--- a/src/jpeg.c
+++ b/src/jpeg.c
@@ -123,6 +123,7 @@ void *a_Jpeg_image(const char *Type, void *P, CA_Callback_t *Call,
DicEntry = a_Dicache_add_entry(web->url);
DicEntry->DecoderData =
Jpeg_new(web->Image, DicEntry->url, DicEntry->version);
+ a_Dicache_ref(DicEntry->url, DicEntry->version);
} else {
/* Repeated image */
a_Dicache_ref(DicEntry->url, DicEntry->version);
diff --git a/src/png.c b/src/png.c
index f7e2de8d..10eec6f0 100644
--- a/src/png.c
+++ b/src/png.c
@@ -474,6 +474,7 @@ void *a_Png_image(const char *Type, void *Ptr, CA_Callback_t *Call,
DicEntry = a_Dicache_add_entry(web->url);
DicEntry->DecoderData =
Png_new(web->Image, DicEntry->url, DicEntry->version);
+ a_Dicache_ref(DicEntry->url, DicEntry->version);
} else {
/* Repeated image */
a_Dicache_ref(DicEntry->url, DicEntry->version);