Skip to content

Commit

Permalink
Merged pull request #246
Browse files Browse the repository at this point in the history
  • Loading branch information
derickr committed Dec 15, 2015
2 parents e14543c + 3db0085 commit c311b18
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 30 deletions.
4 changes: 2 additions & 2 deletions usefulstuff.c
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ FILE *xdebug_fopen(char *fname, char *mode, char *extension, char **new_fname)

int xdebug_format_output_filename(char **filename, char *format, char *script_name)
{
xdebug_str fname = {0, 0, NULL};
xdebug_str fname = XDEBUG_STR_INITIALIZER;
char cwd[128];
TSRMLS_FETCH();

Expand Down Expand Up @@ -718,7 +718,7 @@ int xdebug_format_output_filename(char **filename, char *format, char *script_na

int xdebug_format_file_link(char **filename, const char *error_filename, int error_lineno TSRMLS_DC)
{
xdebug_str fname = {0, 0, NULL};
xdebug_str fname = XDEBUG_STR_INITIALIZER;
char *format = XG(file_link_format);

while (*format)
Expand Down
4 changes: 2 additions & 2 deletions xdebug.c
Original file line number Diff line number Diff line change
Expand Up @@ -1437,7 +1437,7 @@ static void xdebug_throw_exception_hook(zval *exception TSRMLS_DC)
xdebug_brk_info *extra_brk_info;
char *code_str = NULL;
char *exception_trace;
xdebug_str tmp_str = { 0, 0, NULL };
xdebug_str tmp_str = XDEBUG_STR_INITIALIZER;

if (!exception) {
return;
Expand Down Expand Up @@ -1503,7 +1503,7 @@ static void xdebug_throw_exception_hook(zval *exception TSRMLS_DC)
xdebug_log_stack(STR_NAME_VAL(exception_ce->name), Z_STRVAL_P(message), Z_STRVAL_P(file), Z_LVAL_P(line) TSRMLS_CC);
}
if (PG(display_errors)) {
xdebug_str displ_tmp_str = { 0, 0, NULL };
xdebug_str displ_tmp_str = XDEBUG_STR_INITIALIZER;
xdebug_append_error_head(&displ_tmp_str, PG(html_errors), "exception" TSRMLS_CC);
xdebug_str_add(&displ_tmp_str, exception_trace, 0);
xdebug_append_error_footer(&displ_tmp_str, PG(html_errors) TSRMLS_CC);
Expand Down
2 changes: 1 addition & 1 deletion xdebug_branch_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ void xdebug_branch_find_paths(xdebug_branch_info *branch_info)
branch_info->path_info.path_hash = xdebug_hash_alloc(128, NULL);

for (i = 0; i < branch_info->path_info.paths_count; i++) {
xdebug_str str = { 0, 0, NULL };
xdebug_str str = XDEBUG_STR_INITIALIZER;
xdebug_create_key_for_path(branch_info->path_info.paths[i], &str);
xdebug_hash_add(branch_info->path_info.path_hash, str.d, str.l, branch_info->path_info.paths[i]);
xdfree(str.d);
Expand Down
4 changes: 2 additions & 2 deletions xdebug_code_coverage.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ static char *xdebug_find_var_name(zend_execute_data *execute_data TSRMLS_DC)
int cv_len;
zend_op_array *op_array = execute_data->op_array;
#endif
xdebug_str name = {0, 0, NULL};
xdebug_str name = XDEBUG_STR_INITIALIZER;
int gohungfound = 0, is_static = 0;
char *zval_value = NULL;
xdebug_var_export_options *options;
Expand Down Expand Up @@ -941,7 +941,7 @@ void xdebug_code_coverage_start_of_function(zend_op_array *op_array TSRMLS_DC)

void xdebug_code_coverage_end_of_function(zend_op_array *op_array TSRMLS_DC)
{
xdebug_str str = { 0, 0, NULL };
xdebug_str str = XDEBUG_STR_INITIALIZER;
xdebug_path *path = xdebug_path_info_get_path_for_level(XG(paths_stack), XG(level) TSRMLS_CC);
char *file = (char*) STR_NAME_VAL(op_array->filename);
xdebug_func func_info;
Expand Down
4 changes: 2 additions & 2 deletions xdebug_handler_dbgp.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ static xdebug_dbgp_cmd* lookup_cmd(char *cmd)

static xdebug_str *make_message(xdebug_con *context, xdebug_xml_node *message TSRMLS_DC)
{
xdebug_str xml_message = {0, 0, NULL};
xdebug_str xml_message = XDEBUG_STR_INITIALIZER;
xdebug_str *ret;

xdebug_str_ptr_init(ret);
Expand Down Expand Up @@ -301,7 +301,7 @@ static char* return_file_source(char *filename, int begin, int end TSRMLS_DC)
php_stream *stream;
int i = begin;
char *line = NULL;
xdebug_str source = { 0, 0, NULL };
xdebug_str source = XDEBUG_STR_INITIALIZER;

if (i < 0) {
begin = 0;
Expand Down
6 changes: 3 additions & 3 deletions xdebug_stack.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ void xdebug_log_stack(const char *error_type_str, char *buffer, const char *erro
int c = 0; /* Comma flag */
unsigned int j = 0; /* Counter */
char *tmp_name;
xdebug_str log_buffer = {0, 0, NULL};
xdebug_str log_buffer = XDEBUG_STR_INITIALIZER;
int variadic_opened = 0;

i = XDEBUG_LLIST_VALP(le);
Expand Down Expand Up @@ -567,7 +567,7 @@ static char *get_printable_stack(int html, int error_type, char *buffer, const c
char *append_string;
char *error_type_str = xdebug_error_type(error_type);
char *error_type_str_simple = xdebug_error_type_simple(error_type);
xdebug_str str = {0, 0, NULL};
xdebug_str str = XDEBUG_STR_INITIALIZER;

prepend_string = INI_STR("error_prepend_string");
append_string = INI_STR("error_append_string");
Expand Down Expand Up @@ -769,7 +769,7 @@ void xdebug_error_cb(int type, const char *error_filename, const uint error_line
#else
if (type == E_ERROR && strncmp(buffer, "Uncaught exception", 18) == 0) {
#endif
xdebug_str str = {0, 0, NULL};
xdebug_str str = XDEBUG_STR_INITIALIZER;
char *tmp_buf, *p;

/* find first new line */
Expand Down
1 change: 1 addition & 0 deletions xdebug_str.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
void xdebug_str_add(xdebug_str *xs, char *str, int f)
{
int l = strlen(str);

if (xs->l + l > xs->a - 1) {
xs->d = xdrealloc(xs->d, xs->a + l + XDEBUG_STR_PREALLOC);
xs->a = xs->a + l + XDEBUG_STR_PREALLOC;
Expand Down
5 changes: 3 additions & 2 deletions xdebug_str.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@

#include "xdebug_mm.h"

#define XDEBUG_STR_INITIALIZER { 0, 0, NULL }
#define XDEBUG_STR_PREALLOC 1024
#define xdebug_str_ptr_init(str) str = xdmalloc(sizeof(xdebug_str)); str->l = 0; str->a = 0; str->d = NULL;
#define xdebug_str_ptr_dtor(str) xdfree(str->d); xdfree(str)
#define xdebug_str_dtor(str) xdfree(str.d)

typedef struct xdebug_str {
int l;
int a;
signed long l;
signed long a;
char *d;
} xdebug_str;

Expand Down
2 changes: 1 addition & 1 deletion xdebug_superglobals.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ static void dump_hash(xdebug_llist *l, char *name, int name_len, int html, xdebu

char* xdebug_get_printable_superglobals(int html TSRMLS_DC)
{
xdebug_str str = {0, 0, NULL};
xdebug_str str = XDEBUG_STR_INITIALIZER;

dump_hash(&XG(server), "_SERVER", HASH_KEY_SIZEOF("_SERVER"), html, &str TSRMLS_CC);
dump_hash(&XG(get), "_GET", HASH_KEY_SIZEOF("_GET"), html, &str TSRMLS_CC);
Expand Down
6 changes: 3 additions & 3 deletions xdebug_trace_computerized.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ void xdebug_trace_computerized_function_entry(void *ctxt, function_stack_entry *
{
xdebug_trace_computerized_context *context = (xdebug_trace_computerized_context*) ctxt;
char *tmp_name;
xdebug_str str = {0, 0, NULL};
xdebug_str str = XDEBUG_STR_INITIALIZER;

xdebug_str_add(&str, xdebug_sprintf("%d\t", fse->level), 1);
xdebug_str_add(&str, xdebug_sprintf("%d\t", function_nr), 1);
Expand Down Expand Up @@ -197,7 +197,7 @@ void xdebug_trace_computerized_function_entry(void *ctxt, function_stack_entry *
void xdebug_trace_computerized_function_exit(void *ctxt, function_stack_entry *fse, int function_nr TSRMLS_DC)
{
xdebug_trace_computerized_context *context = (xdebug_trace_computerized_context*) ctxt;
xdebug_str str = {0, 0, NULL};
xdebug_str str = XDEBUG_STR_INITIALIZER;

xdebug_str_add(&str, xdebug_sprintf("%d\t", fse->level), 1);
xdebug_str_add(&str, xdebug_sprintf("%d\t", function_nr), 1);
Expand All @@ -214,7 +214,7 @@ void xdebug_trace_computerized_function_exit(void *ctxt, function_stack_entry *f
void xdebug_trace_computerized_function_return_value(void *ctxt, function_stack_entry *fse, int function_nr, zval *return_value TSRMLS_DC)
{
xdebug_trace_computerized_context *context = (xdebug_trace_computerized_context*) ctxt;
xdebug_str str = {0, 0, NULL};
xdebug_str str = XDEBUG_STR_INITIALIZER;
char *tmp_value = NULL;

xdebug_str_add(&str, xdebug_sprintf("%d\t", fse->level), 1);
Expand Down
2 changes: 1 addition & 1 deletion xdebug_trace_html.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void xdebug_trace_html_function_entry(void *ctxt, function_stack_entry *fse, int
xdebug_trace_html_context *context = (xdebug_trace_html_context*) ctxt;
char *tmp_name;
unsigned int j;
xdebug_str str = {0, 0, NULL};
xdebug_str str = XDEBUG_STR_INITIALIZER;

xdebug_str_add(&str, "\t<tr>", 0);
xdebug_str_add(&str, xdebug_sprintf("<td>%d</td>", function_nr), 1);
Expand Down
8 changes: 4 additions & 4 deletions xdebug_trace_textual.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void xdebug_trace_textual_function_entry(void *ctxt, function_stack_entry *fse,
int c = 0; /* Comma flag */
unsigned int j = 0; /* Counter */
char *tmp_name;
xdebug_str str = {0, 0, NULL};
xdebug_str str = XDEBUG_STR_INITIALIZER;

tmp_name = xdebug_show_fname(fse->function, 0, 0 TSRMLS_CC);

Expand Down Expand Up @@ -245,7 +245,7 @@ static void xdebug_return_trace_stack_common(xdebug_str *str, function_stack_ent
void xdebug_trace_textual_function_return_value(void *ctxt, function_stack_entry *fse, int function_nr, zval *return_value TSRMLS_DC)
{
xdebug_trace_textual_context *context = (xdebug_trace_textual_context*) ctxt;
xdebug_str str = {0, 0, NULL};
xdebug_str str = XDEBUG_STR_INITIALIZER;
char *tmp_value;

xdebug_return_trace_stack_common(&str, fse TSRMLS_CC);
Expand All @@ -266,7 +266,7 @@ void xdebug_trace_textual_function_return_value(void *ctxt, function_stack_entry
void xdebug_trace_textual_generator_return_value(void *ctxt, function_stack_entry *fse, int function_nr, zend_generator *generator TSRMLS_DC)
{
xdebug_trace_textual_context *context = (xdebug_trace_textual_context*) ctxt;
xdebug_str str = {0, 0, NULL};
xdebug_str str = XDEBUG_STR_INITIALIZER;
char *tmp_value = NULL;

/* Generator key */
Expand Down Expand Up @@ -305,7 +305,7 @@ void xdebug_trace_textual_assignment(void *ctxt, function_stack_entry *fse, char
{
xdebug_trace_textual_context *context = (xdebug_trace_textual_context*) ctxt;
unsigned int j = 0;
xdebug_str str = {0, 0, NULL};
xdebug_str str = XDEBUG_STR_INITIALIZER;
char *tmp_value;

xdebug_str_addl(&str, " ", 20, 0);
Expand Down
14 changes: 7 additions & 7 deletions xdebug_var.c
Original file line number Diff line number Diff line change
Expand Up @@ -1156,7 +1156,7 @@ void xdebug_var_export(zval **struc, xdebug_str *str, int level, int debug_zval,

char* xdebug_get_zval_value(zval *val, int debug_zval, xdebug_var_export_options *options)
{
xdebug_str str = {0, 0, NULL};
xdebug_str str = XDEBUG_STR_INITIALIZER;
int default_options = 0;
TSRMLS_FETCH();

Expand Down Expand Up @@ -1269,7 +1269,7 @@ static void xdebug_var_synopsis(zval **struc, xdebug_str *str, int level, int de

char* xdebug_get_zval_synopsis(zval *val, int debug_zval, xdebug_var_export_options *options)
{
xdebug_str str = {0, 0, NULL};
xdebug_str str = XDEBUG_STR_INITIALIZER;
int default_options = 0;
TSRMLS_FETCH();

Expand Down Expand Up @@ -1583,7 +1583,7 @@ void xdebug_var_export_text_ansi(zval **struc, xdebug_str *str, int mode, int le

char* xdebug_get_zval_value_text_ansi(zval *val, int mode, int debug_zval, xdebug_var_export_options *options TSRMLS_DC)
{
xdebug_str str = {0, 0, NULL};
xdebug_str str = XDEBUG_STR_INITIALIZER;
int default_options = 0;

if (!options) {
Expand Down Expand Up @@ -1698,7 +1698,7 @@ static void xdebug_var_synopsis_text_ansi(zval **struc, xdebug_str *str, int mod

char* xdebug_get_zval_synopsis_text_ansi(zval *val, int mode, int debug_zval, xdebug_var_export_options *options TSRMLS_DC)
{
xdebug_str str = {0, 0, NULL};
xdebug_str str = XDEBUG_STR_INITIALIZER;
int default_options = 0;

if (!options) {
Expand Down Expand Up @@ -1844,7 +1844,7 @@ static int xdebug_array_element_export_xml_node(zval **zv TSRMLS_DC, int num_arg
xdebug_xml_node *node;
char *name = NULL;
int name_len = 0;
xdebug_str full_name = { 0, 0, NULL };
xdebug_str full_name = XDEBUG_STR_INITIALIZER;

if (options->runtime[level].current_element_nr >= options->runtime[level].start_element_nr &&
options->runtime[level].current_element_nr < options->runtime[level].end_element_nr)
Expand Down Expand Up @@ -2556,7 +2556,7 @@ void xdebug_var_export_fancy(zval **struc, xdebug_str *str, int level, int debug

char* xdebug_get_zval_value_fancy(char *name, zval *val, int *len, int debug_zval, xdebug_var_export_options *options TSRMLS_DC)
{
xdebug_str str = {0, 0, NULL};
xdebug_str str = XDEBUG_STR_INITIALIZER;
int default_options = 0;

if (!options) {
Expand Down Expand Up @@ -2726,7 +2726,7 @@ static void xdebug_var_synopsis_fancy(zval **struc, xdebug_str *str, int level,

char* xdebug_get_zval_synopsis_fancy(char *name, zval *val, int *len, int debug_zval, xdebug_var_export_options *options TSRMLS_DC)
{
xdebug_str str = {0, 0, NULL};
xdebug_str str = XDEBUG_STR_INITIALIZER;
int default_options = 0;

if (!options) {
Expand Down

0 comments on commit c311b18

Please sign in to comment.