[ create a new paste ] login | about

Link: http://codepad.org/d1GIjLU8    [ raw code | output | fork ]

C, pasted on Nov 29:
1
2
3
4
5
6
7
8
9
10
11
12
#include <stdlib.h>
#include <stdio.h>
typedef struct { char x[6*16]; } s;
int main() {
  s* a = (s*) malloc(sizeof(s));
  malloc(16);
  s* b = (s*) malloc(sizeof(s));
  int bytedist = (char*)b - (char*)a;
  int dist = b - a;
  printf("distance %td (%td bytes) pointer: %x mangled pointer: %x\n", dist, bytedist, (int) b, (int) (a + dist));
  return 0;
}


Output:
1
distance 1431655767 (176 bytes) pointer: 804a128 mangled pointer: 804a118


Create a new paste based on this one


Comments: