[ 
https://issues.apache.org/jira/browse/TS-1120?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13216805#comment-13216805
 ] 

Alan M. Carroll edited comment on TS-1120 at 2/26/12 6:45 PM:
--------------------------------------------------------------

{code:title=Examples}

    foo bar; // value.
    ink_zero(bar); // zero bar.

    foo *bar; // pointer.
    ink_zero(bar); // WRONG - makes the pointer @a bar zero.
    ink_zero(*bar); // zero what bar points at.

    foo bar[ZOMG]; // Array of structs.
    ink_zero(bar); // Zero all structs in array.

    foo *bar[ZOMG]; // array of pointers.
    ink_zero(bar); // zero all pointers in the array.
{code}
                
      was (Author: amc):
    {code:title=Examples}
    foo bar; // value.
    ink_zero(bar); // zero bar.

    foo *bar; // pointer.
    ink_zero(bar); // WRONG - makes the pointer @a bar zero.
    ink_zero(*bar); // zero what bar points at.

    foo bar[ZOMG]; // Array of structs.
    ink_zero(bar); // Zero all structs in array.

    foo *bar[ZOMG]; // array of pointers.
    ink_zero(bar); // zero all pointers in the array.
{code}
                  
> Use ink_zero / ats_zero instead of calling memset when zeroing a variable or 
> member.
> ------------------------------------------------------------------------------------
>
>                 Key: TS-1120
>                 URL: https://issues.apache.org/jira/browse/TS-1120
>             Project: Traffic Server
>          Issue Type: Improvement
>          Components: Cleanup
>    Affects Versions: 3.1.2
>            Reporter: Alan M. Carroll
>            Priority: Minor
>              Labels: cleanup, memory, safety
>             Fix For: sometime
>
>
> We have an inline template, ink_zero(foo) which does "memset(&foo, 0, 
> sizeof(foo))". Because this is easy to mess up with a typo, the inline 
> template should be used for safety and clarity. Also, the template should be 
> renamed "ats_zero" to be consistent.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to