changeset 708:697145062347

imported patch dicache-cleanup3
author Jorge Arellano Cid <jcid@dillo.org>
date Mon, 29 Dec 2008 12:36:52 -0300
parents bf52c025c058
children 2e5f159ae6df
files src/dicache.c src/dicache.h src/image.cc src/image.hh
diffstat 4 files changed, 9 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/src/dicache.c	Mon Dec 29 12:36:50 2008 -0300
+++ b/src/dicache.c	Mon Dec 29 12:36:52 2008 -0300
@@ -80,7 +80,6 @@
    entry->height = 0;
    entry->type = DILLO_IMG_TYPE_NOTSET;
    entry->cmap = NULL;
-   entry->linebuf = NULL;
    entry->v_imgbuf = NULL;
    entry->RefCount = 1;
    entry->TotalSize = 0;
@@ -191,7 +190,6 @@
    if (entry) {
       /* Eliminate this dicache entry */
       dFree(entry->cmap);
-      dFree(entry->linebuf);
       a_Bitvec_free(entry->BitVec);
       a_Imgbuf_unref(entry->v_imgbuf);
       dicache_size_total -= entry->TotalSize;
@@ -271,6 +269,7 @@
    if (DicEntry->State < DIC_Close &&
        DicEntry->DecodedSize < Client->BufSize) {
       DicEntry->Decoder(Op, Client);
+      DicEntry->DecodedSize = Client->BufSize; /* necessary ?? */
    }
 
    /* when the data stream is not an image 'v_imgbuf' remains NULL */
@@ -287,15 +286,13 @@
             for (i = 0; i < DicEntry->height; ++i)
                if (a_Bitvec_get_bit(DicEntry->BitVec, (int)i) &&
                    !a_Bitvec_get_bit(Image->BitVec, (int)i) )
-                  a_Image_write(Image, DicEntry->v_imgbuf,
-                                DicEntry->linebuf, i, FALSE);
+                  a_Image_write(Image, i);
          } else {
             for (i = 0; i < DicEntry->height; ++i) {
                if (a_Bitvec_get_bit(DicEntry->BitVec, (int)i) ||
                    !a_Bitvec_get_bit(Image->BitVec, (int)i)   ||
                    DicEntry->ScanNumber > Image->ScanNumber + 1) {
-                  a_Image_write(Image, DicEntry->v_imgbuf,
-                                DicEntry->linebuf, i, FALSE);
+                  a_Image_write(Image, i);
                }
                if (!a_Bitvec_get_bit(DicEntry->BitVec, (int)i))
                   a_Bitvec_clear_bit(Image->BitVec, (int)i);
@@ -320,7 +317,7 @@
 {
    DICacheEntry *DicEntry;
 
-   MSG("a_Dicache_set_parms\n");
+   MSG("a_Dicache_set_parms (%s)\n", URL_STR(url));
    dReturn_if_fail ( Image != NULL && width && height );
    /* Find the DicEntry for this Image */
    DicEntry = Dicache_get_entry_version(url, version);
@@ -328,9 +325,7 @@
    /* Parameters already set? */
    dReturn_if_fail ( DicEntry->State < DIC_SetParms );
 
-   /* Initialize the DicEntry */
-   DicEntry->linebuf = dNew(uchar_t, width * 3);
-   dReturn_if_fail ( DicEntry->linebuf != NULL );
+   MSG("  RefCount=%d version=%d\n", DicEntry->RefCount, DicEntry->version);
 
    /* BUG: there's just one image-type now */
    #define I_RGB 0
@@ -399,7 +394,7 @@
 {
    DICacheEntry *DicEntry;
 
-   MSG("a_Dicache_write\n");
+   _MSG("a_Dicache_write\n");
    dReturn_if_fail ( Image != NULL );
    DicEntry = Dicache_get_entry_version(url, version);
    dReturn_if_fail ( DicEntry != NULL );
@@ -428,8 +423,6 @@
    DicEntry->State = DIC_Close;
    dFree(DicEntry->cmap);
    DicEntry->cmap = NULL;
-   dFree(DicEntry->linebuf);
-   DicEntry->linebuf = NULL;
    a_Bw_close_client(Web->bw, Client->Key);
 }
 
@@ -477,7 +470,6 @@
       while ((entry = node->first)) {
          node->first = entry->next;
          dFree(entry->cmap);
-         dFree(entry->linebuf);
          a_Bitvec_free(entry->BitVec);
          a_Imgbuf_unref(entry->v_imgbuf);
          dicache_size_total -= entry->TotalSize;
--- a/src/dicache.h	Mon Dec 29 12:36:50 2008 -0300
+++ b/src/dicache.h	Mon Dec 29 12:36:52 2008 -0300
@@ -27,7 +27,6 @@
    uint_t width, height;   /* As taken from image data */
    DilloImgType type;      /* Image type */
    uchar_t *cmap;          /* Color map */
-   uchar_t *linebuf;       /* Decompressed RGB buffer for one line */
    void *v_imgbuf;         /* Void pointer to an Imgbuf object */
    uint_t TotalSize;       /* Amount of memory the image takes up */
    int Y;                  /* Current decoding row */
--- a/src/image.cc	Mon Dec 29 12:36:50 2008 -0300
+++ b/src/image.cc	Mon Dec 29 12:36:52 2008 -0300
@@ -128,10 +128,9 @@
 /*
  * Implement the write method
  */
-void a_Image_write(DilloImage *Image, void *v_imgbuf,
-                   const uchar_t *buf, uint_t y, int decode)
+void a_Image_write(DilloImage *Image, uint_t y)
 {
-   MSG("a_Image_write\n");
+   _MSG("a_Image_write\n");
    dReturn_if_fail ( y < Image->height );
 
    /* Update the row in DwImage */
--- a/src/image.hh	Mon Dec 29 12:36:50 2008 -0300
+++ b/src/image.hh	Mon Dec 29 12:36:52 2008 -0300
@@ -63,8 +63,7 @@
                        DilloImgType type);
 void a_Image_set_cmap(DilloImage *Image, const uchar_t *cmap);
 void a_Image_new_scan(DilloImage *image, void *v_imgbuf);
-void a_Image_write(DilloImage *Image, void *v_imgbuf,
-                   const uchar_t *buf, uint_t y, int decode);
+void a_Image_write(DilloImage *Image, uint_t y);
 void a_Image_close(DilloImage *Image);
 
 void a_Image_imgbuf_ref(void *v_imgbuf);