Last change
on this file since 2634 was
409,
checked in by ymipsl, 12 years ago
|
Add improved nectdf internal library src
YM
|
-
Property svn:eol-style set to
native
|
File size:
1.1 KB
|
Line | |
---|
1 | /* Copyright 2009, UCAR/Unidata and OPeNDAP, Inc. |
---|
2 | See the COPYRIGHT file for more information. */ |
---|
3 | |
---|
4 | #include "config.h" |
---|
5 | #include <stdarg.h> |
---|
6 | #include "ocinternal.h" |
---|
7 | #include "ocdebug.h" |
---|
8 | |
---|
9 | int ocdebug; |
---|
10 | |
---|
11 | #ifdef OCCATCHERROR |
---|
12 | /* Place breakpoint here to catch errors close to where they occur*/ |
---|
13 | int |
---|
14 | ocbreakpoint(int err) {return err;} |
---|
15 | |
---|
16 | int |
---|
17 | octhrow(int err) |
---|
18 | { |
---|
19 | if(err == 0) return err; |
---|
20 | return ocbreakpoint(err); |
---|
21 | } |
---|
22 | #endif |
---|
23 | |
---|
24 | int |
---|
25 | xdrerror(void) |
---|
26 | { |
---|
27 | oc_log(LOGERR,"xdr failure"); |
---|
28 | return OCTHROW(OC_EDATADDS); |
---|
29 | } |
---|
30 | |
---|
31 | |
---|
32 | void* |
---|
33 | occalloc(size_t size, size_t nelems) |
---|
34 | { |
---|
35 | return ocmalloc(size*nelems); |
---|
36 | } |
---|
37 | |
---|
38 | void* |
---|
39 | ocmalloc(size_t size) |
---|
40 | { |
---|
41 | void* memory = calloc(size,1); /* use calloc to zero memory*/ |
---|
42 | if(memory == NULL) oc_log(LOGERR,"ocmalloc: out of memory"); |
---|
43 | return memory; |
---|
44 | } |
---|
45 | |
---|
46 | void |
---|
47 | ocfree(void* mem) |
---|
48 | { |
---|
49 | if(mem != NULL) free(mem); |
---|
50 | } |
---|
51 | |
---|
52 | int |
---|
53 | ocpanic(const char* fmt, ...) |
---|
54 | { |
---|
55 | va_list args; |
---|
56 | if(fmt != NULL) { |
---|
57 | va_start(args, fmt); |
---|
58 | vfprintf(stderr, fmt, args); |
---|
59 | fprintf(stderr, "\n" ); |
---|
60 | va_end( args ); |
---|
61 | } else { |
---|
62 | fprintf(stderr, "panic" ); |
---|
63 | } |
---|
64 | fprintf(stderr, "\n" ); |
---|
65 | fflush(stderr); |
---|
66 | return 0; |
---|
67 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.