Coverage Report

Created: 2025-06-24 07:01

/src/ghostpdl/base/claptrap-init.c
Line
Count
Source (jump to first uncovered line)
1
/* Copyright (C) 2015-2023 Artifex Software, Inc.
2
   All Rights Reserved.
3
4
   This software is provided AS-IS with no warranty, either express or
5
   implied.
6
7
   This software is distributed under license and may not be copied,
8
   modified or distributed except as expressly authorized under the terms
9
   of the license contained in the file LICENSE in this distribution.
10
11
   Refer to licensing information at http://www.artifex.com or contact
12
   Artifex Software, Inc.,  39 Mesa Street, Suite 108A, San Francisco,
13
   CA 94129, USA, for further information.
14
*/
15
16
#include "claptrap.h"
17
#include "claptrap-impl.h"
18
19
ClapTrap *ClapTrap_Init(gs_memory_t     *mem,
20
                        int              width,
21
                        int              height,
22
                        int              num_comps,
23
                        const int       *comp_order,
24
                        int              max_x_offset,
25
                        int              max_y_offset,
26
                        ClapTrap_LineFn *get_line,
27
                        void            *get_line_arg)
28
0
{
29
0
    ClapTrap *ct;
30
31
0
    ct = (ClapTrap *)gs_alloc_bytes(mem, sizeof(*ct), "ClapTrap");
32
0
    if (ct == NULL)
33
0
        return NULL;
34
35
0
    ct->width        = width;
36
0
    ct->height       = height;
37
0
    ct->num_comps    = num_comps;
38
0
    ct->comp_order   = comp_order;
39
0
    ct->max_x_offset = max_x_offset;
40
0
    ct->max_y_offset = max_y_offset;
41
0
    ct->get_line     = get_line;
42
0
    ct->get_line_arg = get_line_arg;
43
0
    ct->lines_in_buf = max_y_offset * 2 + 1;
44
0
    ct->lines_read   = 0;
45
0
    ct->y            = 0;
46
0
    ct->span         = width * num_comps;
47
48
0
    ct->linebuf      = gs_alloc_bytes(mem, (size_t)ct->span * ct->lines_in_buf, "ClapTrap linebuf");
49
0
    ct->process      = gs_alloc_bytes(mem, (size_t)ct->width * ct->lines_in_buf, "ClapTrap process");
50
0
    if (ct->linebuf == NULL || ct->process == NULL)
51
0
    {
52
0
        gs_free_object(mem, ct->linebuf, "ClapTrap linebuf");
53
0
        gs_free_object(mem, ct->process, "ClapTrap process");
54
0
        gs_free_object(mem, ct, "ClapTrap");
55
0
        return NULL;
56
0
    }
57
58
0
    return ct;
59
0
}
60
61
void ClapTrap_Fin(gs_memory_t *mem, ClapTrap *ct)
62
0
{
63
0
    if (ct)
64
0
    {
65
0
        gs_free_object(mem, ct->linebuf, "ClapTrap linebuf");
66
0
        gs_free_object(mem, ct->process, "ClapTrap process");
67
0
    }
68
0
    gs_free_object(mem, ct, "ClapTrap");
69
0
}