[gs-commits] ghostpdl branch, master, updated. jbig2dec-0.14-1782-g4641070

[email protected] (Robin Watts) Thu, 31 Oct 2019 15:40:41 +0000 (UTC)
Newsgroups gmane.comp.printing.ghostscript.cvs
Message-ID <[email protected]>
The ghostpdl branch, master has been updated
       via  464107095e614d54417ffd2bedbdc852efee0961 (commit)
      from  5eaccd845c9957dff754ebfdde417fe5d82e5e82 (commit)

----------------------------------------------------------------------
commit 464107095e614d54417ffd2bedbdc852efee0961
Author: Robin Watts <[email protected]>
Date:   Thu Oct 31 15:36:22 2019 +0000

    Update lbp8 device to not use a fixed sized buffer for line data.

diff --git a/devices/gdevlbp8.c b/devices/gdevlbp8.c
index b99e219..5b99cf2 100644
--- a/devices/gdevlbp8.c
+++ b/devices/gdevlbp8.c
@@ -40,7 +40,6 @@ problems
 
 #define X_DPI 300
 #define Y_DPI 300
-#define LINE_SIZE ((X_DPI * 85 / 10 + 7) / 8)	/* bytes per line */
 
 /* The device descriptors */
 static dev_proc_print_page(lbp8_print_page);
@@ -105,20 +104,26 @@ static int
 can_print_page(gx_device_printer *pdev, gp_file *prn_stream,
   const char *init, int init_size, const char *end, int end_size)
 {
-        char data[LINE_SIZE*2];
+        char *data;
         char *out_data;
         int last_line_nro = 0;
+        int line_size = gdev_mem_bytes_per_scan_line((gx_device *)pdev);
+
+        data = (char *)gs_alloc_bytes(pdev->memory,
+                                      line_size*2,
+                                      "lbp8_line_buffer");
+        if (data == NULL)
+            return_error(gs_error_VMerror);
 
         gp_fwrite(init, init_size, 1, prn_stream);		/* initialize */
 
         /* Send each scan line in turn */
         {
             int lnum;
-            int line_size = gdev_mem_bytes_per_scan_line((gx_device *)pdev);
             byte rmask = (byte)(0xff << (-pdev->width & 7));
 
             for ( lnum = 0; lnum < pdev->height; lnum++ ) {
-                char *end_data = data + LINE_SIZE;
+                char *end_data = data + line_size;
                 gdev_prn_copy_scan_lines(pdev, lnum,
                                          (byte *)data, line_size);
                 /* Mask off 1-bits beyond the line width. */
@@ -194,6 +199,8 @@ can_print_page(gx_device_printer *pdev, gp_file *prn_stream,
         if (end != NULL)
             (void)gp_fwrite(end, end_size, 1, prn_stream);
 
+        gs_free_object(pdev->memory, data, "lbp8_line_buffer");
+
         return 0;
 }
 


Summary of changes:
 devices/gdevlbp8.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)