source: main/tags/2.80/indexers/mgpp/text/mg_errors.cpp@ 24540

Last change on this file since 24540 was 8692, checked in by kjdon, 19 years ago

Added the changes from Emanuel Dejanu (Simple Words) - mostly efficiency changes. For example, changing i++ to ++i, delete xxx to delete []xxx, some stuff to do with UCArrays...

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 2.0 KB
Line 
1/**************************************************************************
2 *
3 * mg_errors.cpp -- Error related stuff for mgquery
4 * Copyright (C) 1994 Neil Sharman
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 **************************************************************************/
21
22#define _XOPEN_SOURCE 1
23#define _XOPEN_SOURCE_EXTENDED 1
24
25#include "sysfuncs.h"
26#include "memlib.h"
27
28#include "mg_errors.h"
29
30int mg_errno = MG_NOERROR;
31
32char *mg_errorstrs[] =
33{
34 "No error",
35 "Out of memory",
36 "File \"%s\" not found",
37 "Bad magic number in \"%s\"",
38 "Error reading \"%s\"",
39 "MG_BUFTOOSMALL",
40 "Files required for level 2 and 3 inversion are missing"};
41
42
43/* [RJM 07/98: Memory Leak] -- rest of file */
44
45static char null_data[] = "";
46char *mg_error_data = null_data;
47
48
49void MgErrorData (char *s)
50{
51 /* free the current error string, unless it is the null string */
52 if ((mg_error_data != NULL) && (mg_error_data != null_data)) {
53 delete []mg_error_data;
54 mg_error_data = null_data;
55 }
56
57 /* make a copy of the string */
58 mg_error_data = Xstrdup (s);
59
60 /* if the alloc failed set the error to the null string */
61 if (!mg_error_data) mg_error_data = null_data;
62}
63
64
65void MgErrorDeinit (void)
66{
67 /* free the current error string, unless it is the null string */
68 if ((mg_error_data != NULL) && (mg_error_data != null_data)) {
69 delete []mg_error_data;
70 mg_error_data = null_data;
71 }
72}
Note: See TracBrowser for help on using the repository browser.