annotate src/debug.c @ 292:e0e5844d91b3

patch from Leo Antunes for Status: header
author Carl Byington <carl@five-ten-sg.com>
date Sun, 19 Jun 2011 09:08:29 -0700
parents cc8ee701f190
children 7a91e30826d8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
48
f66078abed38 more fixes for 64 bit format
carl
parents: 46
diff changeset
1 #include "define.h"
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
2
33
12cac756bc05 enable -d option, but if not specified, don't generate a debug file
carl
parents: 31
diff changeset
3
46
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
4 struct pst_debug_func {
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
5 char * name;
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
6 struct pst_debug_func *next;
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 129
diff changeset
7 };
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 129
diff changeset
8
202
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
9
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
10 #define NUM_COL 32
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
11 #define MAX_DEPTH 32
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
12
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
13 static struct pst_debug_func *func_head = NULL;
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
14 static int func_depth = 0;
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
15 static char indent[MAX_DEPTH*4+1];
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
16 static FILE *debug_fp = NULL;
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
17 #ifdef HAVE_SEMAPHORE_H
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
18 static sem_t* debug_mutex = NULL;
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
19 #endif
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
20
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
21
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
22 void pst_debug_lock()
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
23 {
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
24 #ifdef HAVE_SEMAPHORE_H
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
25 if (debug_mutex) sem_wait(debug_mutex);
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
26 #endif
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
27 }
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
28
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
29
202
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
30 void pst_debug_unlock()
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
31 {
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
32 #ifdef HAVE_SEMAPHORE_H
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
33 if (debug_mutex) sem_post(debug_mutex);
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
34 #endif
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
35 }
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
36
176
ac6e22c8a9cf build separate libpst, libpst-libs, libpst-devel rpms.
Carl Byington <carl@five-ten-sg.com>
parents: 172
diff changeset
37
202
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
38 void pst_debug_init(const char* fname, void* output_mutex) {
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
39 #ifdef HAVE_SEMAPHORE_H
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
40 debug_mutex = (sem_t*)output_mutex;
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
41 #endif
260
156cf548c764 adding more debug code
Carl Byington <carl@five-ten-sg.com>
parents: 202
diff changeset
42 memset(indent, ' ', MAX_DEPTH*4);
156cf548c764 adding more debug code
Carl Byington <carl@five-ten-sg.com>
parents: 202
diff changeset
43 indent[MAX_DEPTH*4] = '\0';
202
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
44 if (debug_fp) pst_debug_close();
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
45 if (!fname) return;
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
46 if ((debug_fp = fopen(fname, "wb")) == NULL) {
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
47 fprintf(stderr, "Opening of file %s failed\n", fname);
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
48 exit(1);
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
49 }
73
3cb02cb1e6cd Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents: 70
diff changeset
50 }
3cb02cb1e6cd Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents: 70
diff changeset
51
3cb02cb1e6cd Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents: 70
diff changeset
52
202
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
53 void pst_debug_func(const char* function) {
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
54 struct pst_debug_func *func_ptr = pst_malloc (sizeof(struct pst_debug_func));
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
55 func_ptr->name = strdup(function);
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
56 func_ptr->next = func_head;
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
57 func_head = func_ptr;
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
58 func_depth++;
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
59 }
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
60
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
61
202
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
62 void pst_debug_func_ret() {
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
63 //remove the head item
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
64 struct pst_debug_func *func_ptr = func_head;
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
65 if (func_head) {
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
66 func_head = func_head->next;
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
67 free(func_ptr->name);
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
68 free(func_ptr);
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
69 func_depth--;
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
70 } else {
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
71 DIE(("function list is empty!\n"));
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
72 }
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
73 }
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
74
33
12cac756bc05 enable -d option, but if not specified, don't generate a debug file
carl
parents: 31
diff changeset
75
202
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
76 static void pst_debug_info(int line, const char* file);
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
77 static void pst_debug_info(int line, const char* file) {
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
78 int le = (func_depth > MAX_DEPTH) ? MAX_DEPTH : func_depth;
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
79 if (le > 0) le--;
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
80 char *func = (func_head ? func_head->name : "No Function");
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
81 pst_debug_lock();
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
82 fprintf(debug_fp, "%06d %.*s%s %s(%d) ", getpid(), le*4, indent, func, file, line);
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
83 }
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
84
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
85
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
86 void pst_debug(int line, const char* file, const char *fmt, ...) {
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
87 if (debug_fp) {
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
88 pst_debug_info(line, file);
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
89 va_list ap;
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
90 va_start(ap,fmt);
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
91 vfprintf(debug_fp, fmt, ap);
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
92 va_end(ap);
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
93 fflush(debug_fp);
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
94 pst_debug_unlock();
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
95 }
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
96 }
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
97
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
98
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
99 void pst_debug_hexdump(int line, const char *file, const char *buf, size_t size, int cols, int delta) {
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
100 if (debug_fp) {
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
101 pst_debug_info(line, file);
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
102 pst_debug_hexdumper(debug_fp, buf, size, cols, delta);
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
103 pst_debug_unlock();
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
104 }
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
105 }
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
106
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
107
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
108 void pst_debug_hexdumper(FILE *out, const char *buf, size_t size, int cols, int delta) {
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
109 int le = (func_depth > MAX_DEPTH) ? MAX_DEPTH : func_depth;
70
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 48
diff changeset
110 size_t off = 0, toff;
46
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
111 int count = 0;
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
112
46
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
113 if (!out) return; // no file
202
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
114
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
115 if (cols == -1) cols = NUM_COL;
46
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
116 fprintf(out, "\n");
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
117 while (off < size) {
202
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
118 fprintf(out, "%06d %.*s%06"PRIx64"\t:", getpid(), le*4, indent, (int64_t)(off+delta));
46
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
119 toff = off;
202
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
120 while (count < cols && off < size) {
73
3cb02cb1e6cd Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents: 70
diff changeset
121 fprintf(out, "%02hhx ", (unsigned char)buf[off]);
46
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
122 off++; count++;
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
123 }
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
124 off = toff;
202
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
125 while (count < cols) {
46
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
126 // only happens at end of block to pad the text over to the text column
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
127 fprintf(out, " ");
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
128 count++;
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
129 }
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
130 count = 0;
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
131 fprintf(out, ":");
202
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
132 while (count < cols && off < size) {
46
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
133 fprintf(out, "%c", isgraph(buf[off])?buf[off]:'.');
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
134 off++; count ++;
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
135 }
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
136
46
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
137 fprintf(out, "\n");
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
138 count=0;
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
139 }
33
12cac756bc05 enable -d option, but if not specified, don't generate a debug file
carl
parents: 31
diff changeset
140
46
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
141 fprintf(out, "\n");
202
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
142 fflush(out);
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
143 }
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
144
33
12cac756bc05 enable -d option, but if not specified, don't generate a debug file
carl
parents: 31
diff changeset
145
46
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
146 void pst_debug_close(void) {
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
147 while (func_head) {
202
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
148 struct pst_debug_func *func_ptr = func_head;
46
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
149 func_head = func_head->next;
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
150 free(func_ptr->name);
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
151 free(func_ptr);
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
152 }
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
153 if (debug_fp) fclose(debug_fp);
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
154 debug_fp = NULL;
33
12cac756bc05 enable -d option, but if not specified, don't generate a debug file
carl
parents: 31
diff changeset
155 }
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
156
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
157
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 129
diff changeset
158 void *pst_malloc(size_t size) {
46
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
159 void *mem = malloc(size);
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
160 if (!mem) {
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 129
diff changeset
161 fprintf(stderr, "pst_malloc: Out Of memory [req: %ld]\n", (long)size);
46
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
162 exit(1);
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
163 }
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
164 return mem;
33
12cac756bc05 enable -d option, but if not specified, don't generate a debug file
carl
parents: 31
diff changeset
165 }
12cac756bc05 enable -d option, but if not specified, don't generate a debug file
carl
parents: 31
diff changeset
166
289
cc8ee701f190 pst_block_offset elements are unsigned; consistent usage of pst_malloc and pst_realloc
Carl Byington <carl@five-ten-sg.com>
parents: 260
diff changeset
167
cc8ee701f190 pst_block_offset elements are unsigned; consistent usage of pst_malloc and pst_realloc
Carl Byington <carl@five-ten-sg.com>
parents: 260
diff changeset
168 void *pst_realloc(void *ptr, size_t size) {
cc8ee701f190 pst_block_offset elements are unsigned; consistent usage of pst_malloc and pst_realloc
Carl Byington <carl@five-ten-sg.com>
parents: 260
diff changeset
169 void *mem = realloc(ptr, size);
cc8ee701f190 pst_block_offset elements are unsigned; consistent usage of pst_malloc and pst_realloc
Carl Byington <carl@five-ten-sg.com>
parents: 260
diff changeset
170 if (!mem) {
cc8ee701f190 pst_block_offset elements are unsigned; consistent usage of pst_malloc and pst_realloc
Carl Byington <carl@five-ten-sg.com>
parents: 260
diff changeset
171 fprintf(stderr, "pst_realloc: Out Of memory [req: %ld]\n", (long)size);
cc8ee701f190 pst_block_offset elements are unsigned; consistent usage of pst_malloc and pst_realloc
Carl Byington <carl@five-ten-sg.com>
parents: 260
diff changeset
172 exit(1);
cc8ee701f190 pst_block_offset elements are unsigned; consistent usage of pst_malloc and pst_realloc
Carl Byington <carl@five-ten-sg.com>
parents: 260
diff changeset
173 }
cc8ee701f190 pst_block_offset elements are unsigned; consistent usage of pst_malloc and pst_realloc
Carl Byington <carl@five-ten-sg.com>
parents: 260
diff changeset
174 return mem;
cc8ee701f190 pst_block_offset elements are unsigned; consistent usage of pst_malloc and pst_realloc
Carl Byington <carl@five-ten-sg.com>
parents: 260
diff changeset
175 }