Coverage Report

Created: 2023-12-08 06:59

/src/aspell/common/error.cpp
Line
Count
Source (jump to first uncovered line)
1
// This file is part of The New Aspell
2
// Copyright (C) 2001 by Kevin Atkinson under the GNU LGPL license
3
// version 2.0 or 2.1.  You should have received a copy of the LGPL
4
// license along with this library if you did not you can find
5
// it at http://www.gnu.org/.
6
7
#include <string.h>
8
#include <stdlib.h>
9
10
#include "error.hpp"
11
12
namespace acommon {
13
14
  bool Error::is_a(ErrorInfo const * to_find) const 
15
3.00k
  {
16
3.00k
    const ErrorInfo * e = err;
17
3.00k
    while (e) {
18
3.00k
      if (e == to_find) return true;
19
0
      e = e->isa;
20
0
    }
21
0
    return false;
22
3.00k
  }
23
24
  Error::Error(const Error & other)
25
0
  {
26
0
    if (other.mesg) {
27
0
      mesg = (char *)malloc(strlen(other.mesg) + 1);
28
0
      strcpy(const_cast<char *>(mesg), other.mesg);
29
0
    }
30
0
    err = other.err;
31
0
  }
32
33
  Error & Error::operator=(const Error & other)
34
0
  {
35
0
    if (mesg)
36
0
      free(const_cast<char *>(mesg));
37
0
    if (other.mesg) {
38
0
      unsigned int len = strlen(other.mesg) + 1;
39
0
      mesg = (char *)malloc(len);
40
0
      memcpy(const_cast<char *>(mesg), other.mesg, len);
41
0
    }
42
0
    err = other.err;
43
0
    return *this;
44
0
  }
45
46
  Error::~Error()
47
29.4k
  {
48
29.4k
    if (mesg)
49
29.4k
      free(const_cast<char *>(mesg));
50
29.4k
  }
51
52
}