My Project  UNKNOWN_GIT_VERSION
Data Structures | Functions | Variables
omError.c File Reference
#include <stdarg.h>
#include "omalloc.h"

Go to the source code of this file.

Data Structures

struct  omErrorString_s
 

Functions

const char * omError2String (omError_t error)
 
const char * omError2Serror (omError_t error)
 
omError_t omReportError (omError_t error, omError_t report_error, OM_FLR_DECL, const char *fmt,...)
 
void omErrorBreak ()
 

Variables

omError_t om_ErrorStatus = omError_NoError
 
omError_t om_InternalErrorStatus = omError_NoError
 
static const struct omErrorString_s om_ErrorStrings []
 
int om_CallErrorHook = 1
 

Data Structure Documentation

◆ omErrorString_s

struct omErrorString_s

Definition at line 14 of file omError.c.

Data Fields
omError_t error
char * s_error
char * string

Function Documentation

◆ omError2Serror()

const char* omError2Serror ( omError_t  error)

Definition at line 63 of file omError.c.

64 {
65  int i = 0;
66  while (! (om_ErrorStrings[i].string == NULL && om_ErrorStrings[i].error == omError_MaxError))
67  {
69  i++;
70  }
71  return "omError_UnKnown";
72 }
int i
Definition: cfEzgcd.cc:125
void error(const char *fmt,...)
Definition: emacs.cc:55
char * s_error
Definition: omError.c:17
static const struct omErrorString_s om_ErrorStrings[]
Definition: omError.c:22
@ omError_MaxError
Definition: omError.h:42
#define NULL
Definition: omList.c:10

◆ omError2String()

const char* omError2String ( omError_t  error)

Definition at line 52 of file omError.c.

53 {
54  int i = 0;
55  while (! (om_ErrorStrings[i].string == NULL && om_ErrorStrings[i].error == omError_MaxError))
56  {
58  i++;
59  }
60  return "undocumented error";
61 }
char * string
Definition: omError.c:18

◆ omErrorBreak()

void omErrorBreak ( )

Definition at line 135 of file omError.c.

136 {}

◆ omReportError()

omError_t omReportError ( omError_t  error,
omError_t  report_error,
OM_FLR_DECL  ,
const char *  fmt,
  ... 
)

Definition at line 78 of file omError.c.

80 {
81  int max_check, max_track;
82 
83  if (report_error == omError_MaxError) return error;
84  /* reset MaxTrack and MaxCheck to prevent infinite loop, in case
85  printf allocates memory */
86  max_check = om_Opts.MaxCheck;
87  max_track = om_Opts.MaxTrack;
88  om_Opts.MaxCheck = 0;
89  om_Opts.MaxTrack = 0;
90 
92  om_ErrorStatus = (report_error == omError_NoError ? error : report_error);
93 
94  if (om_Opts.HowToReportErrors && om_ErrorStatus != omError_NoError)
95  {
96  /* to avoid spurious error msg in 64 bit mode*/
97  if (om_ErrorStatus == omError_StickyBin) return error;
98  fprintf(stderr, "***%s: %s", omError2Serror(om_ErrorStatus), omError2String(om_ErrorStatus));
99 
100 #ifdef OM_INTERNAL_DEBUG
101  if (om_ErrorStatus != error)
102  fprintf(stderr, "\n___%s: %s", omError2Serror(error), omError2String(error));
103 #endif
104 
105  if (om_Opts.HowToReportErrors > 2 && fmt != NULL && *fmt != '\0')
106  {
107  va_list ap;
108  va_start(ap, fmt);
109  fputs( ": ",stderr);
110  vfprintf(stderr, fmt, ap);
111  va_end(ap);
112  }
113 
114  if (om_Opts.HowToReportErrors > 1)
115  {
116 #ifndef OM_NDEBUG
117  fputs("\n occurred at: ",stderr);
118  if (! _omPrintCurrentBackTrace(stderr, OM_FLR_VAL))
119  fputs(" ??",stderr);
120 #endif
121  }
122  fputc('\n',stderr);
123  fflush(stderr);
124  }
125  if (om_CallErrorHook)
126  om_Opts.ErrorHook();
127 
128  om_Opts.MaxCheck = max_check;
129  om_Opts.MaxTrack = max_track;
130  return error;
131 }
Definition: ap.h:40
omError_t om_ErrorStatus
Definition: omError.c:11
const char * omError2String(omError_t error)
Definition: omError.c:52
int om_CallErrorHook
Definition: omError.c:75
const char * omError2Serror(omError_t error)
Definition: omError.c:63
omError_t om_InternalErrorStatus
Definition: omError.c:12
@ omError_NoError
Definition: omError.h:18
@ omError_StickyBin
Definition: omError.h:41
omOpts_t om_Opts
Definition: omOpts.c:11
int _omPrintCurrentBackTrace(FILE *fd, OM_FLR_DECL)
Definition: omRet2Info.c:270

Variable Documentation

◆ om_CallErrorHook

int om_CallErrorHook = 1

Definition at line 75 of file omError.c.

◆ om_ErrorStatus

omError_t om_ErrorStatus = omError_NoError

Definition at line 11 of file omError.c.

◆ om_ErrorStrings

const struct omErrorString_s om_ErrorStrings[]
static
Initial value:
=
{
{omError_NoError, "omError_NoError", "no error"},
{omError_Unknown, "omError_Unknown", "unknown error" },
{omError_MemoryCorrupted, "omError_MemoryCorrupted", "memory corrupted"},
{omError_InternalBug, "omError_InternalBug", "internal omalloc bug"},
{omError_NullAddr, "omError_NullAddr", "addr is NULL"},
{omError_InvalidRangeAddr, "omError_InvalidRangeAddr", "addr not in valid range"},
{omError_FalseAddr, "omError_FalseAddr", "addr not as returned by omalloc"},
{omError_FalseAddrOrMemoryCorrupted, "omError_FalseAddrOrMemoryCorrupted", "addr not as returned by omalloc or memory corrupted", },
{omError_WrongSize, "omError_WrongSize", "wrong size specification of addr"},
{omError_FreedAddr, "omError_FreedAddr", "addr had previosuly been freed"},
{omError_FreedAddrOrMemoryCorrupted, "omError_FreedAddrOrMemoryCorrupted", "addr had previosuly been freed or memory corrupted"},
{omError_WrongBin, "omError_WrongBin", "addr is not from given Bin"},
{omError_UnknownBin, "omError_UnknownBin", "given Bin is unknown"},
{omError_NotBinAddr, "omError_NotBinAddr", "addr is not a BinAddr"},
{omError_UnalignedAddr, "omError_UnalignedAddr", "addr is unaligned"},
{omError_NullSizeAlloc, "omError_NullSizeAlloc", "alloc of size 0"},
{omError_ListCycleError, "omError_ListCycleError", "list has cycles"},
{omError_SortedListError, "omError_SortedListError", "sorted list is unsorted"},
{omError_KeptAddrListCorrupted, "omError_KeptAddrListCorrupted", "list of kept addresses are corrupted"},
{omError_FrontPattern, "omError_FrontPattern", "written to front of addr"},
{omError_BackPattern, "omError_BackPattern", "written after end of addr"},
{omError_FreePattern, "omError_FreePattern", "written into freed memory"},
{omError_NotString, "omError_NotString", "string not null terminated"},
{omError_StickyBin, "omError_StickyBin", "wrong handling of sticky bins"},
}
@ omError_WrongSize
Definition: omError.h:26
@ omError_ListCycleError
Definition: omError.h:34
@ omError_BackPattern
Definition: omError.h:38
@ omError_NullAddr
Definition: omError.h:22
@ omError_NullSizeAlloc
Definition: omError.h:33
@ omError_FrontPattern
Definition: omError.h:39
@ omError_UnalignedAddr
Definition: omError.h:32
@ omError_MemoryCorrupted
Definition: omError.h:21
@ omError_FreedAddr
Definition: omError.h:27
@ omError_UnknownBin
Definition: omError.h:30
@ omError_FreedAddrOrMemoryCorrupted
Definition: omError.h:28
@ omError_NotString
Definition: omError.h:40
@ omError_SortedListError
Definition: omError.h:35
@ omError_KeptAddrListCorrupted
Definition: omError.h:36
@ omError_InternalBug
Definition: omError.h:20
@ omError_NotBinAddr
Definition: omError.h:31
@ omError_InvalidRangeAddr
Definition: omError.h:23
@ omError_FalseAddr
Definition: omError.h:24
@ omError_WrongBin
Definition: omError.h:29
@ omError_Unknown
Definition: omError.h:19
@ omError_FreePattern
Definition: omError.h:37
@ omError_FalseAddrOrMemoryCorrupted
Definition: omError.h:25

Definition at line 12 of file omError.c.

◆ om_InternalErrorStatus

omError_t om_InternalErrorStatus = omError_NoError

Definition at line 12 of file omError.c.