source: XIOS/dev/dev_olga/extern/src_netcdf4/ocdebug.c @ 1620

Last change on this file since 1620 was 409, checked in by ymipsl, 11 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
9int ocdebug;
10
11#ifdef OCCATCHERROR
12/* Place breakpoint here to catch errors close to where they occur*/
13int
14ocbreakpoint(int err) {return err;}
15
16int
17octhrow(int err)
18{
19    if(err == 0) return err;
20    return ocbreakpoint(err);
21}
22#endif
23
24int
25xdrerror(void)
26{
27    oc_log(LOGERR,"xdr failure");
28    return OCTHROW(OC_EDATADDS);
29}
30
31
32void*
33occalloc(size_t size, size_t nelems)
34{
35    return ocmalloc(size*nelems);
36}
37
38void*
39ocmalloc(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
46void
47ocfree(void* mem)
48{
49    if(mem != NULL) free(mem);
50}
51
52int
53ocpanic(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.