[Libpst-commits] r52 - trunk
Joseph Nahmias
jello at alioth.debian.org
Thu Dec 7 06:16:57 CET 2006
Author: jello
Date: 2006-12-07 06:16:57 +0100 (Thu, 07 Dec 2006)
New Revision: 52
Modified:
trunk/debug.c
trunk/define.h
Log:
_debug_write(): make sure buf is always freed, fix some signedness warnings
Modified: trunk/debug.c
===================================================================
--- trunk/debug.c 2006-12-07 04:46:23 UTC (rev 51)
+++ trunk/debug.c 2006-12-07 05:16:57 UTC (rev 52)
@@ -29,13 +29,13 @@
void _debug_init(char *fname);
void _debug_msg_info (int line, char *file, int type);
void _debug_msg(char* fmt, ...);
-void _debug_hexdump(char *x, int y, int cols);
+void _debug_hexdump(unsigned char *x, int y, int cols);
void _debug_func(char *function);
void _debug_func_ret();
void _debug_close();
void _debug_write();
void _debug_write_msg(struct _debug_item *item, char *fmt, va_list *ap, int size);
-void _debug_write_hex(struct _debug_item *item, char *buf, int size, int col);
+void _debug_write_hex(struct _debug_item *item, unsigned char *buf, int size, int col);
void * xmalloc(size_t size);
// the largest text size we will store in memory. Otherwise we
@@ -202,7 +202,7 @@
}
}
-void _debug_hexdump(char *x, int y, int cols) {
+void _debug_hexdump(unsigned char *x, int y, int cols) {
struct _debug_item *temp;
if (debug_fp == NULL)
return;
@@ -261,7 +261,7 @@
void _debug_write() {
size_t size, ptr, funcname, filename, text, end;
- char *buf, rec_type;
+ char *buf = NULL, rec_type;
long index_pos = ftell (debug_fp), file_pos = index_pos;
// add 2. One for the pointer to the next index,
// one for the count of this index
@@ -287,6 +287,7 @@
index[index_ptr++] = file_pos;
size = strlen(item_ptr->function)+strlen(item_ptr->file)+
strlen(item_ptr->text) + 3; //for the three \0s
+ if (buf) free(buf);
buf = xmalloc(size+1);
ptr = 0;
funcname=ptr;
@@ -318,6 +319,7 @@
fwrite(&mfile_rec, sizeof(mfile_rec), 1, debug_fp);
}
fwrite(buf, 1, ptr, debug_fp);
+ if (buf) free(buf); buf = NULL;
item_head = item_ptr->next;
free(item_ptr->function);
free(item_ptr->file);
@@ -334,6 +336,7 @@
fseek(debug_fp, 0, SEEK_END);
item_ptr = item_head = item_tail = NULL;
free(index);
+ if (buf) free(buf); buf = NULL;
}
void _debug_write_msg(struct _debug_item *item, char *fmt, va_list *ap, int size) {
@@ -394,7 +397,7 @@
// that should do it...
}
-void _debug_write_hex(struct _debug_item *item, char *buf, int size, int col) {
+void _debug_write_hex(struct _debug_item *item, unsigned char *buf, int size, int col) {
struct _debug_file_rec_l lfile_rec;
unsigned char rec_type;
int index_size = 3 * sizeof(int);
Modified: trunk/define.h
===================================================================
--- trunk/define.h 2006-12-07 04:46:23 UTC (rev 51)
+++ trunk/define.h 2006-12-07 05:16:57 UTC (rev 52)
@@ -57,7 +57,7 @@
void _debug_init(char *fname);
void _debug_msg_info (int line, char *file, int type);
void _debug_msg_text(char* fmt, ...);
-void _debug_hexdump(char *x, int y, int cols);
+void _debug_hexdump(unsigned char *x, int y, int cols);
void _debug_func(char *function);
void _debug_func_ret();
void _debug_close(void);
More information about the Libpst-commits
mailing list