Return unique_xmalloc_ptr from gdbscm_scm_to_string
This changes gdbscm_scm_to_string to return a unique_xmalloc_ptr and then fixes all the callers. This allows for the removal of some cleanups. gdb/ChangeLog 2018-07-17 Tom Tromey <tom@tromey.com> * guile/scm-param.c (pascm_set_func, pascm_show_func) (compute_enum_list, pascm_set_param_value_x) (gdbscm_parameter_value): Update. * guile/guile-internal.h (gdbscm_scm_to_string): Update. (gdbscm_scm_to_host_string): Update. * guile/scm-math.c (vlscm_convert_typed_value_from_scheme): Update. * guile/scm-cmd.c (cmdscm_add_completion): Update. * guile/scm-pretty-print.c (ppscm_print_string_repr): Update. * guile/scm-string.c (gdbscm_scm_to_string): Return unique_xmalloc_ptr. (gdbscm_scm_to_host_string): Likewise.
This commit is contained in:
parent
a1a31cb8dc
commit
c6c6149af4
7 changed files with 51 additions and 53 deletions
|
@ -113,10 +113,9 @@ gdbscm_call_scm_to_stringn (void *datap)
|
|||
If STRICT is zero, then escape sequences are used for characters that
|
||||
can't be converted, and EXCEPT_SCMP may be passed as NULL.
|
||||
|
||||
Space for the result is allocated with malloc, caller must free.
|
||||
It is an error to call this if STRING is not a string. */
|
||||
|
||||
char *
|
||||
gdb::unique_xmalloc_ptr<char>
|
||||
gdbscm_scm_to_string (SCM string, size_t *lenp,
|
||||
const char *charset, int strict, SCM *except_scmp)
|
||||
{
|
||||
|
@ -136,7 +135,7 @@ gdbscm_scm_to_string (SCM string, size_t *lenp,
|
|||
if (gdbscm_is_false (scm_result))
|
||||
{
|
||||
gdb_assert (data.result != NULL);
|
||||
return data.result;
|
||||
return gdb::unique_xmalloc_ptr<char> (data.result);
|
||||
}
|
||||
gdb_assert (gdbscm_is_exception (scm_result));
|
||||
*except_scmp = scm_result;
|
||||
|
@ -214,10 +213,9 @@ gdbscm_scm_from_string (const char *string, size_t len,
|
|||
|
||||
Returns NULL if there is a conversion error, with the exception object
|
||||
stored in *EXCEPT_SCMP.
|
||||
Space for the result is allocated with malloc, caller must free.
|
||||
It is an error to call this if STRING is not a string. */
|
||||
|
||||
char *
|
||||
gdb::unique_xmalloc_ptr<char>
|
||||
gdbscm_scm_to_host_string (SCM string, size_t *lenp, SCM *except_scmp)
|
||||
{
|
||||
return gdbscm_scm_to_string (string, lenp, host_charset (), 1, except_scmp);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue