X-Git-Url: https://www.hackdaworld.org/gitweb/?a=blobdiff_plain;f=moldyn.c;h=515a27315bf8455c45a59d81eb278431b7d0f44c;hb=a40aa116ffcefe415a0146c9ea10918ce5b4f888;hp=9d782d657fbc89c5ab800ed7705de48c87739a1e;hpb=76f807f6dda48b6d606309cea79005e612e4f665;p=physik%2Fposic.git diff --git a/moldyn.c b/moldyn.c index 9d782d6..515a273 100644 --- a/moldyn.c +++ b/moldyn.c @@ -185,17 +185,15 @@ int create_lattice(t_moldyn *moldyn,u8 type,double lc,int element,double mass, int count; int ret; t_3dvec origin; - t_atom *atom; count=a*b*c; - atom=moldyn->atom; if(type==FCC) count*=4; if(type==DIAMOND) count*=8; - atom=malloc(count*sizeof(t_atom)); - if(atom==NULL) { + moldyn->atom=malloc(count*sizeof(t_atom)); + if(moldyn->atom==NULL) { perror("malloc (atoms)"); return -1; } @@ -204,10 +202,10 @@ int create_lattice(t_moldyn *moldyn,u8 type,double lc,int element,double mass, switch(type) { case FCC: - ret=fcc_init(a,b,c,lc,atom,&origin); + ret=fcc_init(a,b,c,lc,moldyn->atom,&origin); break; case DIAMOND: - ret=diamond_init(a,b,c,lc,atom,&origin); + ret=diamond_init(a,b,c,lc,moldyn->atom,&origin); break; default: printf("unknown lattice type (%02x)\n",type); @@ -225,10 +223,10 @@ int create_lattice(t_moldyn *moldyn,u8 type,double lc,int element,double mass, moldyn->count=count; while(count) { - atom[count-1].element=element; - atom[count-1].mass=mass; - atom[count-1].attr=attr; - atom[count-1].bnum=bnum; + moldyn->atom[count-1].element=element; + moldyn->atom[count-1].mass=mass; + moldyn->atom[count-1].attr=attr; + moldyn->atom[count-1].bnum=bnum; count-=1; }