Local Constants

Sometimes you want to symbolically define a constant for a limited scope. Buryint the constant in some header file is not terribly useful or easy to access when the constant isn't used anywhere else. For example in this code, the constants '8' and '16' (see the /* !!! */) could be locally defined to avoid an error-prone maintenance situation...

        ...     
        else
        {       if(acx_write_mem(g_myAgentID,
                        blank_bytes,
                        ddr_offset_now,
                        16,           /* !!! */
                        ACX_TRANSFER_KERNEL_SPACE_MEMCPY) < 1)
                {
                        return -EFAULT;
                }
                ddr_offset_now += 16; /* !!! */
        }

        /* Only copy the initial vector for CBC modes
         */
        if (theHeader->isCBC)
        {
                if(acx_write_mem(g_myAgentID,
                        theJob.initialVector,
                        ddr_offset_now,
                        8, /* !!! */
                        ACX_TRANSFER_KERNEL_SPACE_MEMCPY) < 1)
                {
                        return -EFAULT;
                }
        }
        else
        {       if(acx_write_mem(g_myAgentID,
                        blank_bytes,
                        ddr_offset_now,
                        8,  /* !!! */
                        ACX_TRANSFER_KERNEL_SPACE_MEMCPY) < 1)
                {
                        return -EFAULT;
                }
        }
        ddr_offset_now += 8; /* !!! */

-- MattWalsh - 05 Apr 2002

Topic revision: r1 - 06 Apr 2002 - MattWalsh
 
This site is powered by the TWiki collaboration platformCopyright © 2008-2012 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback