may be NULL.
* ui-file.c (ui_file_xstrdup): Don't dereference LENGTH if it is
NULL.
* aix-thread.c (aix_thread_extra_thread_info): Pass NULL as length
parameter to ui_file_xstrdup.
* arm-tdep.c (_initialize_arm_tdep): Ditto.
* infrun.c (print_target_wait_results): Ditto.
* language.c (add_language): Ditto.
* linespec.c (cplusplus_error): Ditto.
* remote.c (escape_buffer): Ditto.
* typeprint.c (type_to_string): Ditto.
* utils.c (error_stream): Ditto.
* varobj.c (value_get_print_value): Ditto.
* xtensa-tdep.c (xtensa_verify_config): Replace `dummy' local with
`length' local. Pass it to ui_file_xstrdup, and avoid an strlen
call.
* gdbarch.sh (verify_gdbarch): Ditto.
* gdbarch.c: Regenerate.
* cli/cli-setshow.c (do_setshow_command): Pass NULL as length
parameter to ui_file_xstrdup.
* python/python-frame.c (frapy_str): Ditto.
* python/python-type.c (typy_str): Use the length local instead of
calling strlen.
* python/python-value.c (valpy_str): Pass NULL as length parameter
to ui_file_xstrdup.
+2009-08-14 Pedro Alves <pedro@codesourcery.com>
+
+ * ui-file.h (ui_file_xstrdup): Mention that the length argument
+ may be NULL.
+ * ui-file.c (ui_file_xstrdup): Don't dereference LENGTH if it is
+ NULL.
+ * aix-thread.c (aix_thread_extra_thread_info): Pass NULL as length
+ parameter to ui_file_xstrdup.
+ * arm-tdep.c (_initialize_arm_tdep): Ditto.
+ * infrun.c (print_target_wait_results): Ditto.
+ * language.c (add_language): Ditto.
+ * linespec.c (cplusplus_error): Ditto.
+ * remote.c (escape_buffer): Ditto.
+ * typeprint.c (type_to_string): Ditto.
+ * utils.c (error_stream): Ditto.
+ * varobj.c (value_get_print_value): Ditto.
+ * xtensa-tdep.c (xtensa_verify_config): Replace `dummy' local with
+ `length' local. Pass it to ui_file_xstrdup, and avoid an strlen
+ call.
+ * gdbarch.sh (verify_gdbarch): Ditto.
+ * gdbarch.c: Regenerate.
+ * cli/cli-setshow.c (do_setshow_command): Pass NULL as length
+ parameter to ui_file_xstrdup.
+ * python/python-frame.c (frapy_str): Ditto.
+ * python/python-type.c (typy_str): Use the length local instead of
+ calling strlen.
+ * python/python-value.c (valpy_str): Pass NULL as length parameter
+ to ui_file_xstrdup.
+
2009-08-13 Doug Evans <dje@google.com>
* utils.c (gnu_debuglink_crc32): Store crc32_table as unsigned int
pthdb_suspendstate_t suspendstate;
pthdb_detachstate_t detachstate;
int cancelpend;
- long length;
static char *ret = NULL;
if (!PD_TID (thread->ptid))
xfree (ret); /* Free old buffer. */
- ret = ui_file_xstrdup (buf, &length);
+ ret = ui_file_xstrdup (buf, NULL);
ui_file_delete (buf);
return ret;
_("The valid values are:\n"),
regdesc,
_("The default is \"std\"."));
- helptext = ui_file_xstrdup (stb, &length);
+ helptext = ui_file_xstrdup (stb, NULL);
ui_file_delete (stb);
add_setshow_enum_cmd("disassembler", no_class,
ui_out_field_stream (uiout, "value", stb);
else
{
- long length;
- char *value = ui_file_xstrdup (stb->stream, &length);
+ char *value = ui_file_xstrdup (stb->stream, NULL);
make_cleanup (xfree, value);
if (c->show_value_func != NULL)
c->show_value_func (gdb_stdout, from_tty, c, value);
{
struct ui_file *log;
struct cleanup *cleanups;
- long dummy;
+ long length;
char *buf;
log = mem_fileopen ();
cleanups = make_cleanup_ui_file_delete (log);
/* Skip verify of record_special_symbol, has predicate */
/* Skip verify of has_global_solist, invalid_p == 0 */
/* Skip verify of has_global_breakpoints, invalid_p == 0 */
- buf = ui_file_xstrdup (log, &dummy);
+ buf = ui_file_xstrdup (log, &length);
make_cleanup (xfree, buf);
- if (strlen (buf) > 0)
+ if (length > 0)
internal_error (__FILE__, __LINE__,
_("verify_gdbarch: the following are invalid ...%s"),
buf);
{
struct ui_file *log;
struct cleanup *cleanups;
- long dummy;
+ long length;
char *buf;
log = mem_fileopen ();
cleanups = make_cleanup_ui_file_delete (log);
fi
done
cat <<EOF
- buf = ui_file_xstrdup (log, &dummy);
+ buf = ui_file_xstrdup (log, &length);
make_cleanup (xfree, buf);
- if (strlen (buf) > 0)
+ if (length > 0)
internal_error (__FILE__, __LINE__,
_("verify_gdbarch: the following are invalid ...%s"),
buf);
char *status_string = target_waitstatus_to_string (ws);
struct ui_file *tmp_stream = mem_fileopen ();
char *text;
- long len;
/* The text is split over several lines because it was getting too long.
Call fprintf_unfiltered (gdb_stdlog) once so that the text is still
"infrun: %s\n",
status_string);
- text = ui_file_xstrdup (tmp_stream, &len);
+ text = ui_file_xstrdup (tmp_stream, NULL);
/* This uses %s in part to handle %'s in the text, but also to avoid
a gcc error: the format attribute requires a string literal. */
int i;
struct ui_file *tmp_stream;
- long len;
if (lang->la_magic != LANG_MAGIC)
{
}
xfree (language_set_doc);
- language_set_doc = ui_file_xstrdup (tmp_stream, &len);
+ language_set_doc = ui_file_xstrdup (tmp_stream, NULL);
ui_file_delete (tmp_stream);
add_setshow_enum_cmd ("language", class_support,
cplusplus_error (const char *name, const char *fmt, ...)
{
struct ui_file *tmp_stream;
- long len;
char *message;
tmp_stream = mem_fileopen ();
make_cleanup_ui_file_delete (tmp_stream);
"(Note leading single quote.)"),
name, name);
- message = ui_file_xstrdup (tmp_stream, &len);
- make_cleanup (xfree, message);
- throw_error (NOT_FOUND_ERROR, "%s", message);
+ message = ui_file_xstrdup (tmp_stream, NULL);
+ make_cleanup (xfree, message);
+ throw_error (NOT_FOUND_ERROR, "%s", message);
}
/* Return the number of methods described for TYPE, including the
frapy_str (PyObject *self)
{
char *s;
- long len;
PyObject *result;
struct ui_file *strfile;
strfile = mem_fileopen ();
fprint_frame_id (strfile, ((frame_object *) self)->frame_id);
- s = ui_file_xstrdup (strfile, &len);
+ s = ui_file_xstrdup (strfile, NULL);
result = PyString_FromString (s);
xfree (s);
{
volatile struct gdb_exception except;
char *thetype = NULL;
+ long length = 0;
PyObject *result;
TRY_CATCH (except, RETURN_MASK_ALL)
{
struct cleanup *old_chain;
struct ui_file *stb;
- long length;
stb = mem_fileopen ();
old_chain = make_cleanup_ui_file_delete (stb);
GDB_PY_HANDLE_EXCEPTION (except);
}
- result = PyUnicode_Decode (thetype, strlen (thetype), host_charset (), NULL);
+ result = PyUnicode_Decode (thetype, length, host_charset (), NULL);
xfree (thetype);
return result;
valpy_str (PyObject *self)
{
char *s = NULL;
- long dummy;
struct ui_file *stb;
struct cleanup *old_chain;
PyObject *result;
{
common_val_print (((value_object *) self)->value, stb, 0,
&opts, python_language);
- s = ui_file_xstrdup (stb, &dummy);
+ s = ui_file_xstrdup (stb, NULL);
}
GDB_PY_HANDLE_EXCEPTION (except);
struct cleanup *old_chain;
struct ui_file *stb;
char *str;
- long length;
stb = mem_fileopen ();
old_chain = make_cleanup_ui_file_delete (stb);
fputstrn_unfiltered (buf, n, 0, stb);
- str = ui_file_xstrdup (stb, &length);
+ str = ui_file_xstrdup (stb, NULL);
do_cleanups (old_chain);
return str;
}
type_to_string (struct type *type)
{
char *s = NULL;
- long dummy;
struct ui_file *stb;
struct cleanup *old_chain;
volatile struct gdb_exception except;
TRY_CATCH (except, RETURN_MASK_ALL)
{
type_print (type, "", stb, -1);
- s = ui_file_xstrdup (stb, &dummy);
+ s = ui_file_xstrdup (stb, NULL);
}
if (except.reason < 0)
s = NULL;
}
char *
-ui_file_xstrdup (struct ui_file *file,
- long *length)
+ui_file_xstrdup (struct ui_file *file, long *length)
{
struct accumulated_ui_file acc;
acc.buffer = NULL;
ui_file_put (file, do_ui_file_xstrdup, &acc);
if (acc.buffer == NULL)
acc.buffer = xstrdup ("");
- *length = acc.length;
+ if (length != NULL)
+ *length = acc.length;
return acc.buffer;
}
\f
/* Returns a freshly allocated buffer containing the entire contents
of FILE (as determined by ui_file_put()) with a NUL character
- appended. LENGTH is set to the size of the buffer minus that
- appended NUL. */
+ appended. LENGTH, if not NULL, is set to the size of the buffer
+ minus that appended NUL. */
extern char *ui_file_xstrdup (struct ui_file *file, long *length);
NORETURN void
error_stream (struct ui_file *stream)
{
- long len;
- char *message = ui_file_xstrdup (stream, &len);
+ char *message = ui_file_xstrdup (stream, NULL);
make_cleanup (xfree, message);
error (("%s"), message);
}
value_get_print_value (struct value *value, enum varobj_display_formats format,
struct varobj *var)
{
- long dummy;
struct ui_file *stb;
struct cleanup *old_chain;
gdb_byte *thevalue = NULL;
}
else
common_val_print (value, stb, 0, &opts, current_language);
- thevalue = ui_file_xstrdup (stb, &dummy);
+ thevalue = ui_file_xstrdup (stb, NULL);
do_cleanups (old_chain);
return thevalue;
struct ui_file *log;
struct cleanup *cleanups;
struct gdbarch_tdep *tdep;
- long dummy;
+ long length;
char *buf;
tdep = gdbarch_tdep (gdbarch);
if (tdep->a0_base == -1)
fprintf_unfiltered (log, _("\n\ta0_base: No Ax registers"));
- buf = ui_file_xstrdup (log, &dummy);
+ buf = ui_file_xstrdup (log, &length);
make_cleanup (xfree, buf);
- if (strlen (buf) > 0)
+ if (length > 0)
internal_error (__FILE__, __LINE__,
_("the following are invalid: %s"), buf);
do_cleanups (cleanups);