Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 43326406b25c2b0d5c843529c4cd4aa90aed85bb
Ticket: 3129448fffffffffffffffffffffffffffffffff
possible over-allocation on 64-bit platforms
User & Date: nijtmans on 2010-12-06 23:12:12
Changes

  1. icomment:
    Here is a small test program (try it on any UNIX machine) which shows the
    dirrerence between substracting two sizes or determining the offset.
    
    This program prints:
        12 8
    
    Here I used a long long as data type in stead of an int. It will occur
    on any machine where sizeof(int) = 8.
    
    =====================================================
    #include <stdio.h>
    #define TclOffset(type, field) \
    ((int) ((char *) &((type *) 0)->field))
    typedef struct {
    long long dummy;
    char buf[4];
    } mytype;
    void main() {
    mytype x;
    int answer1 = sizeof(x) - sizeof(x.buf);
    int answer2 = (unsigned)TclOffset(mytype, buf);
    printf("%d %d\n", answer1, answer2);
    }
    
    
    
  2. login: "nijtmans"
  3. mimetype: "text/plain"
  4. username: "nijtmans"