Skip to content

Commit

Permalink
Don't use static (empty) strings as placeholder, but NULL instead
Browse files Browse the repository at this point in the history
  • Loading branch information
derickr committed Jan 8, 2018
1 parent d1b3b46 commit 68c9cd4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions xdebug.c
Expand Up @@ -415,9 +415,9 @@ static void php_xdebug_init_globals (zend_xdebug_globals *xg TSRMLS_DC)
xg->trace_context = NULL;
xg->in_debug_info = 0;
xg->coverage_enable = 0;
xg->previous_filename = "";
xg->previous_filename = NULL;
xg->previous_file = NULL;
xg->previous_mark_filename = "";
xg->previous_mark_filename = NULL;
xg->previous_mark_file = NULL;
xg->paths_stack = NULL;
xg->branches.size = 0;
Expand Down Expand Up @@ -1223,7 +1223,7 @@ PHP_RINIT_FUNCTION(xdebug)
XG(dead_code_analysis_tracker_offset) = zend_xdebug_cc_run_offset;
XG(dead_code_last_start_id) = 1;
XG(code_coverage_filter_offset) = zend_xdebug_filter_offset;
XG(previous_filename) = "";
XG(previous_filename) = NULL;
XG(previous_file) = NULL;
XG(gc_stats_file) = NULL;
XG(gc_stats_filename) = NULL;
Expand Down Expand Up @@ -1416,7 +1416,7 @@ ZEND_MODULE_POST_ZEND_DEACTIVATE_D(xdebug)
XG(branches).last_branch_nr = NULL;
XG(branches).size = 0;
}
XG(previous_mark_filename) = "";
XG(previous_mark_filename) = NULL;

return SUCCESS;
}
Expand Down
6 changes: 3 additions & 3 deletions xdebug_branch_info.c
Expand Up @@ -339,7 +339,7 @@ void xdebug_branch_info_mark_reached(char *file_name, char *function_name, zend_
xdebug_coverage_function *function;
xdebug_branch_info *branch_info;

if (strcmp(XG(previous_mark_filename), file_name) == 0) {
if (XG(previous_mark_filename) && strcmp(XG(previous_mark_filename), file_name) == 0) {
file = XG(previous_mark_file);
} else {
if (!xdebug_hash_find(XG(code_coverage), file_name, strlen(file_name), (void *) &file)) {
Expand Down Expand Up @@ -401,7 +401,7 @@ void xdebug_branch_info_mark_end_of_function_reached(char *filename, char *funct
xdebug_branch_info *branch_info;
xdebug_path *path;

if (strcmp(XG(previous_mark_filename), filename) == 0) {
if (XG(previous_mark_filename) && strcmp(XG(previous_mark_filename), filename) == 0) {
file = XG(previous_mark_file);
} else {
if (!xdebug_hash_find(XG(code_coverage), filename, strlen(filename), (void *) &file)) {
Expand Down Expand Up @@ -434,7 +434,7 @@ void xdebug_branch_info_add_branches_and_paths(char *filename, char *function_na
xdebug_coverage_file *file;
xdebug_coverage_function *function;

if (strcmp(XG(previous_filename), filename) == 0) {
if (XG(previous_filename) && strcmp(XG(previous_filename), filename) == 0) {
file = XG(previous_file);
} else {
/* Check if the file already exists in the hash */
Expand Down
6 changes: 3 additions & 3 deletions xdebug_code_coverage.c
Expand Up @@ -471,7 +471,7 @@ void xdebug_count_line(char *filename, int lineno, int executable, int deadcode
xdebug_coverage_file *file;
xdebug_coverage_line *line;

if (strcmp(XG(previous_filename), filename) == 0) {
if (XG(previous_filename) && strcmp(XG(previous_filename), filename) == 0) {
file = XG(previous_file);
} else {
/* Check if the file already exists in the hash */
Expand Down Expand Up @@ -974,9 +974,9 @@ PHP_FUNCTION(xdebug_stop_code_coverage)
}
if (XG(do_code_coverage)) {
if (cleanup) {
XG(previous_filename) = "";
XG(previous_filename) = NULL;
XG(previous_file) = NULL;
XG(previous_mark_filename) = "";
XG(previous_mark_filename) = NULL;
XG(previous_mark_file) = NULL;
xdebug_hash_destroy(XG(code_coverage));
XG(code_coverage) = xdebug_hash_alloc(32, xdebug_coverage_file_dtor);
Expand Down

0 comments on commit 68c9cd4

Please sign in to comment.