Mercurial > libpst
comparison src/debug.c @ 123:ab2a11e72250
more cleanup of #include files.
common.h is the only file allowed to include system .h files
unprotected by autoconf HAVE_ symbols. define.h is the only other file
allowed to include system .h files. define.h is never installed;
common.h is installed if we are building the shared library.
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Tue, 03 Feb 2009 10:59:10 -0800 |
parents | bdb38b434c0a |
children | 23a36ac0514d |
comparison
equal
deleted
inserted
replaced
122:bdb38b434c0a | 123:ab2a11e72250 |
---|---|
249 | 249 |
250 void pst_debug_write() { | 250 void pst_debug_write() { |
251 size_t size, ptr, funcname, filename, text, end; | 251 size_t size, ptr, funcname, filename, text, end; |
252 char *buf = NULL, rec_type; | 252 char *buf = NULL, rec_type; |
253 if (!debug_fp) return; // no file | 253 if (!debug_fp) return; // no file |
254 off_t index_pos = ftello(debug_fp); | 254 uint64_t index_pos = ftello(debug_fp); |
255 off_t file_pos = index_pos; | 255 uint64_t file_pos = index_pos; |
256 // add 2. One for the pointer to the next index, | 256 // add 2. One for the pointer to the next index, |
257 // one for the count of this index | 257 // one for the count of this index |
258 int index_size = ((curr_items+2) * sizeof(off_t)); | 258 int index_size = ((curr_items+2) * sizeof(uint64_t)); |
259 off_t *index; | 259 uint64_t *index; |
260 int index_ptr = 0; | 260 int index_ptr = 0; |
261 struct pst_debug_file_rec_m mfile_rec; | 261 struct pst_debug_file_rec_m mfile_rec; |
262 struct pst_debug_file_rec_l lfile_rec; | 262 struct pst_debug_file_rec_l lfile_rec; |
263 | 263 |
264 if (curr_items == 0) return; // no items to write. | 264 if (curr_items == 0) return; // no items to write. |
265 | 265 |
266 index = (off_t*)xmalloc(index_size); | 266 index = (uint64_t*)xmalloc(index_size); |
267 memset(index, 0, index_size); // valgrind, avoid writing uninitialized data | 267 memset(index, 0, index_size); // valgrind, avoid writing uninitialized data |
268 file_pos += index_size; | 268 file_pos += index_size; |
269 // write the index first, we will re-write it later, but | 269 // write the index first, we will re-write it later, but |
270 // we want to allocate the space | 270 // we want to allocate the space |
271 pst_debug_fwrite(index, index_size, 1, debug_fp); | 271 pst_debug_fwrite(index, index_size, 1, debug_fp); |
333 | 333 |
334 void pst_debug_write_msg(struct pst_debug_item *item, const char *fmt, va_list *ap, int size) { | 334 void pst_debug_write_msg(struct pst_debug_item *item, const char *fmt, va_list *ap, int size) { |
335 struct pst_debug_file_rec_l lfile_rec; | 335 struct pst_debug_file_rec_l lfile_rec; |
336 struct pst_debug_file_rec_m mfile_rec; | 336 struct pst_debug_file_rec_m mfile_rec; |
337 unsigned char rec_type; | 337 unsigned char rec_type; |
338 int index_size = 3 * sizeof(off_t); | 338 int index_size = 3 * sizeof(uint64_t); |
339 off_t index[3]; | 339 uint64_t index[3]; |
340 off_t index_pos, file_pos; | 340 uint64_t index_pos, file_pos; |
341 char zero = '\0'; | 341 char zero = '\0'; |
342 unsigned int end; | 342 unsigned int end; |
343 if (!debug_fp) return; // no file | 343 if (!debug_fp) return; // no file |
344 index[0] = 1; // only one item in this index | 344 index[0] = 1; // only one item in this index |
345 index[1] = 0; // valgrind, avoid writing uninitialized data | 345 index[1] = 0; // valgrind, avoid writing uninitialized data |
395 | 395 |
396 | 396 |
397 void pst_debug_write_hex(struct pst_debug_item *item, char *buf, size_t size, int col) { | 397 void pst_debug_write_hex(struct pst_debug_item *item, char *buf, size_t size, int col) { |
398 struct pst_debug_file_rec_l lfile_rec; | 398 struct pst_debug_file_rec_l lfile_rec; |
399 unsigned char rec_type; | 399 unsigned char rec_type; |
400 int index_size = 3 * sizeof(off_t); | 400 int index_size = 3 * sizeof(uint64_t); |
401 off_t index_pos, file_pos, index[3]; | 401 uint64_t index_pos, file_pos, index[3]; |
402 char zero='\0'; | 402 char zero='\0'; |
403 if (!debug_fp) return; // no file | 403 if (!debug_fp) return; // no file |
404 index[0] = 1; // only one item in this index run | 404 index[0] = 1; // only one item in this index run |
405 index[1] = 0; // valgrind, avoid writing uninitialized data | 405 index[1] = 0; // valgrind, avoid writing uninitialized data |
406 index[2] = 0; // "" | 406 index[2] = 0; // "" |