Title: Samsung Enterprise Portal mySingle

HI,

Instead of initializing this array to 0 in else part, it can be initialize it to 0 at the time of declaration.

It will initialize all array elements to zero and thus we can eliminate the else part..what say ?

e.g:-

- char *found = (char *) malloc(count);
- memset(found, 0, count);
+ char found[count] = {0};      

 

--

Regards

Manjeet

------- Original Message -------

Sender : Cyril Hrubis<chru...@suse.cz>

Date : Jun 09, 2015 18:00 (GMT+09:00)

Title : Re: Re: [LTP] [PATCH]: Fix memory leak

 

Hi!
> This patch make 'found' a static array to avoid memory leaks.
>
> Signed-off-by: Cyril Hrubis
> Signed-off-by: Manjeet Pawar
> ---
>  utils/sctp/testlib/sctputil.c |    3 +--
>  1 files changed, 1 insertions(+), 2 deletions(-)
>
> diff --git a/utils/sctp/testlib/sctputil.c b/utils/sctp/testlib/sctputil.c
> index c670af6..e7333e5 100644
> --- a/utils/sctp/testlib/sctputil.c
> +++ b/utils/sctp/testlib/sctputil.c
> @@ -370,8 +370,7 @@ int test_peer_addr(int sk, sctp_assoc_t asoc, sockaddr_storage_t *peers, int cou
>   struct sockaddr *sa_addr;
>   socklen_t addrs_size = 0;
>   void *addrbuf;
> - char *found = (char *) malloc(count);
> - memset(found, 0, count);
> + char found[count];
>  
>   error = sctp_getpaddrs(sk, asoc, &addrs);
>   if (-1 == error) {

I've added initialization to 0 to the else branch down below, since we
removed the memset and pushed, thanks.

--
Cyril Hrubis
chru...@suse.cz

 

 

------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to