This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] gdb/ada-lang.c: one malloc -> unique_ptr<[]>
- From: Joel Brobecker <brobecker at adacore dot com>
- To: Pedro Alves <palves at redhat dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Thu, 17 Nov 2016 05:23:48 -0800
- Subject: Re: [PATCH] gdb/ada-lang.c: one malloc -> unique_ptr<[]>
- Authentication-results: sourceware.org; auth=none
- References: <1479345063-18205-1-git-send-email-palves@redhat.com>
> Switching gdb to use gnulib's C++ namespace mode reveals we're calling
> malloc instead of xmalloc here:
>
> ..../src/gdb/ada-lang.c: In function ‘value* ada_value_primitive_packed_val(value*, const gdb_byte*, long int, int, int, type*)’:
> ..../src/gdb/ada-lang.c:2592:50: error: call to ‘malloc’ declared with attribute warning: The symbol ::malloc refers to the system function. Use gnulib::malloc instead. [-Werror]
> staging = (gdb_byte *) malloc (staging_len);
Humpf. Oversight on my part.
> Since we want to get rid of all cleanups, fix this by switching to
> new[] and unique_ptr<[]> instead, while at it.
>
> Regtested on Fedora 23.
>
> gdb/ChangeLog:
> yyyy-mm-dd Pedro Alves <palves@redhat.com>
>
> * ada-lang.c (ada_value_primitive_packed_val): Use unique_ptr and
> new gdb_byte[] instead of malloc and cleanups.
I think I understand the patch, and it looks good to me.
Thanks, Pedro.
--
Joel