[dovecot-cvs] dovecot/src/lib imem.h,1.9,1.10 failures.c,1.25,1.26
cras at dovecot.org
cras at dovecot.org
Tue May 3 20:02:45 EEST 2005
Update of /var/lib/cvs/dovecot/src/lib
In directory talvi:/tmp/cvs-serv21727
Modified Files:
imem.h failures.c
Log Message:
Added i_free_and_null() macro and first use case.
Index: imem.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/imem.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- imem.h 21 Sep 2003 16:39:29 -0000 1.9
+++ imem.h 3 May 2005 17:02:42 -0000 1.10
@@ -10,12 +10,19 @@
void *i_malloc(size_t size);
void *i_realloc(void *mem, size_t old_size, size_t new_size);
+/* Free the memory. Currently it also sets memory to NULL, but that shouldn't
+ be relied on as it's only extra safety check. It might as well be later
+ changed to some invalid pointer causing segfault, or removed completely
+ in some "optimization".. */
#define i_free(mem) \
STMT_START { \
p_free(default_pool, mem); \
(mem) = NULL; \
} STMT_END
+/* A macro that's guaranteed to set mem = NULL. */
+#define i_free_and_null(mem) i_free(mem)
+
/* string functions */
char *i_strdup(const char *str);
char *i_strdup_empty(const char *str); /* like i_strdup(), but if str == "", return NULL */
Index: failures.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/failures.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- failures.c 9 Jul 2004 19:08:35 -0000 1.25
+++ failures.c 3 May 2005 17:02:42 -0000 1.26
@@ -438,9 +438,6 @@
log_info_fd = stderr;
}
- i_free(log_prefix);
- log_prefix = NULL;
-
- i_free(log_stamp_format);
- log_stamp_format = NULL;
+ i_free_and_null(log_prefix);
+ i_free_and_null(log_stamp_format);
}
More information about the dovecot-cvs
mailing list