Maybe it's best time to talk about sizeof(char)

Do we need to sizeof(char)? I just that is problem of coding convention.
such as (a == 0) and (!a).
Is there any predefined convention about this case?

On Wed, May 23, 2012 at 10:52 AM, ChunEon Park <her...@naver.com> wrote:
> FYI, sizeof will be computed at the compile time.
>
>
> -----Original Message-----
> From: "ChunEon Park"&lt;her...@naver.com&gt;
> To: &lt;enlightenment-devel@lists.sourceforge.net&gt;; 
> &lt;enlightenment-...@lists.sourceforge.net&gt;;
> Cc:
> Sent: 2012-05-23 (수) 10:49:24
> Subject: Re: [E-devel] E SVN: hyoyoung trunk/elementary/src/lib
>
>
> The most I prefer is to use sizeof( variable );
>
>
> No harmful for performance and would be better if the buffer type is changed.
>
>
>
>
> -----Original Message-----
> From: "Enlightenment SVN"&lt;no-reply&gt;@enlightenment.org&gt;
> To: &lt;enlightenment-svn&gt;@lists.sourceforge.net&gt;;
> Cc:
> Sent: 2012-05-23 (수) 09:53:08
> Subject: E SVN: hyoyoung trunk/elementary/src/lib
>
>
> Log:
> elementary/cnp: don't calc sizeof char at buffer malloc
>
>
>
> Author:       hyoyoung
> Date:         2012-05-22 17:53:07 -0700 (Tue, 22 May 2012)
> New Revision: 71337
> Trac:         http://trac.enlightenment.org/e/changeset/71337
>
>
> Modified:
>  trunk/elementary/src/lib/elm_cnp.c
>
>
> Modified: trunk/elementary/src/lib/elm_cnp.c
> ===================================================================
> --- trunk/elementary/src/lib/elm_cnp.c2012-05-23 00:51:11 UTC (rev 71336)
> +++ trunk/elementary/src/lib/elm_cnp.c2012-05-23 00:53:07 UTC (rev 71337)
> @@ -785,7 +785,7 @@
>    char *mkupstr;
>
>
>    data = notify-&gt;data;
> -   str = malloc(sizeof(char) * (data-&gt;length + 1));
> +   str = malloc((data-&gt;length + 1));
>    if (!str) return 0;
>    strncpy(str, (char *)data-&gt;data, data-&gt;length);
>    str[data-&gt;length] = '\0';
> @@ -840,7 +840,7 @@
>      }
>    else
>      {
> -        stripstr = p = malloc(data-&gt;length * sizeof(char) + 1);
> +        stripstr = p = malloc(data-&gt;length + 1);
>         if (!stripstr) return 0;
>         memcpy(stripstr, data-&gt;data, data-&gt;length);
>         stripstr[data-&gt;length] = 0;
> @@ -985,7 +985,7 @@
>
>
>    cnp_debug("Got some HTML: Checking encoding is useful\n");
>    data = notify-&gt;data;
> -   char *stripstr = malloc(sizeof(char) * (data-&gt;length + 1));
> +   char *stripstr = malloc(data-&gt;length + 1);
>    if (!stripstr) return 0;
>    strncpy(stripstr, (char *)data-&gt;data, data-&gt;length);
>    stripstr[data-&gt;length] = '\0';
>
>
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> enlightenment-svn mailing list
> enlightenment-...@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/enlightenment-svn
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> enlightenment-devel mailing list
> enlightenment-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> enlightenment-devel mailing list
> enlightenment-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to