Return-Path: Delivered-To: apmail-new-httpd-archive@apache.org Received: (qmail 19658 invoked by uid 500); 16 May 2000 20:51:56 -0000 Mailing-List: contact new-httpd-help@apache.org; run by ezmlm Precedence: bulk X-No-Archive: yes Reply-To: new-httpd@apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list new-httpd@apache.org Received: (qmail 19643 invoked from network); 16 May 2000 20:51:55 -0000 Date: Tue, 16 May 2000 13:50:50 -0700 (PDT) From: Greg Stein To: new-httpd@apache.org Subject: sizeof stylistic convention (was: cvs commit: ... mod_cgi.c mod_include.c) In-Reply-To: <20000516201931.7725.qmail@locus.apache.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Rating: locus.apache.org 1.6.2 0/1000/N On 16 May 2000 stoddard@locus.apache.org wrote: >... > --- mod_include.c 2000/05/16 01:59:07 1.28 > +++ mod_include.c 2000/05/16 20:19:29 1.29 > @@ -1129,7 +1129,7 @@ > > if (rr->status == HTTP_OK && rr->finfo.protection != 0) { > memcpy((char *) finfo, (const char *) &rr->finfo, > - sizeof(struct stat)); > + sizeof(rr->finfo)); > ap_destroy_sub_req(rr); > return 0; > } This is a stylistic convention that I'd like to call attention to. When doing a sizeof(), it is "best" to do a sizeof of the target variable or expression, rather than hard-coding a type. When the type changes, then the sizeof doesn't need to be maintained. Some examples: p = malloc(sizeof(*p)); // be careful; don't write sizeof(p) ! :-) memcpy(p1, p2, sizeof(p1)); // or sizeof(p2) Cheers, -g -- Greg Stein, http://www.lyra.org/