Przeglądaj źródła

Use explicit comparison with NULL, it's more clear and shuts off gcc,
which otherwise compain that condition is always true when argument is
pointer to the struct allocated on stack.

Maxim Sobolev 17 lat temu
rodzic
commit
2577e2f300
1 zmienionych plików z 3 dodań i 3 usunięć
  1. 3 3
      lib/cds/sstr.h

+ 3 - 3
lib/cds/sstr.h

@@ -77,7 +77,7 @@ char *zt_strdup(const char*src);
 
 
 /** frees string content if allocated */
 /** frees string content if allocated */
 /* void str_free_content(str_t *s); */
 /* void str_free_content(str_t *s); */
-#define str_free_content(str)	do { if (str) { \
+#define str_free_content(str)	do { if (str != NULL) { \
 		if (((str)->len > 0) && ((str)->s)) cds_free((str)->s);\
 		if (((str)->len > 0) && ((str)->s)) cds_free((str)->s);\
 		(str)->len = 0; \
 		(str)->len = 0; \
 		(str)->s = 0; \
 		(str)->s = 0; \
@@ -85,13 +85,13 @@ char *zt_strdup(const char*src);
 
 
 /** frees string content if allocated and then the string itself */
 /** frees string content if allocated and then the string itself */
 /* void str_free(str_t *s); */
 /* void str_free(str_t *s); */
-#define str_free(str)	do { if (str) { \
+#define str_free(str)	do { if (str != NULL) { \
 		if (((str)->len > 0) && ((str)->s)) cds_free((str)->s);\
 		if (((str)->len > 0) && ((str)->s)) cds_free((str)->s);\
 		cds_free(str); \
 		cds_free(str); \
 	} } while (0)
 	} } while (0)
 
 
 /* clears string content */
 /* clears string content */
-#define str_clear(str)	do { if (str) { \
+#define str_clear(str)	do { if (str != NULL) { \
 		(str)->len = 0; \
 		(str)->len = 0; \
 		(str)->s = 0; \
 		(str)->s = 0; \
 	} } while (0)
 	} } while (0)