fixed incorrect table allocation
authorBerk Hess <hess@kth.se>
Fri, 16 Mar 2012 16:27:45 +0000 (17:27 +0100)
committerRoland Schulz <roland@utk.edu>
Fri, 16 Mar 2012 16:54:04 +0000 (12:54 -0400)
This caused problems after commit 553d4b13.
The bug was already in older versions, but was hidden due to
the over allocation for pointer alignment.

Change-Id: Ifc50ee66fd4e963aab20ff1231c90a472fd5c443

src/mdlib/forcerec.c

index 0136396fe66a2a912d3efeb7108a39711a0d7c9b..6b17c0a70f8887455101eef6428ee28a40f5d977 100644 (file)
@@ -1040,15 +1040,11 @@ static void make_nbf_tables(FILE *fp,const output_env_t oenv,
    */
 
   /* For performance reasons we want
-   * the table data to be aligned to 16-byte. This is accomplished
-   * by allocating 16 bytes extra to a temporary pointer, and then
-   * calculating an aligned pointer. This new pointer must not be
-   * used in a free() call, but thankfully we're sloppy enough not
-   * to do this...
+   * the table data to be aligned to 16-byte. The pointer could be freed
+   * but currently isn't.
    */
-  
-  snew_aligned(nbl->vdwtab,8*nbl->tab.n,16);
-  snew_aligned(nbl->coultab,4*nbl->tab.n,16);
+  snew_aligned(nbl->vdwtab,8*(nbl->tab.n+1),16);
+  snew_aligned(nbl->coultab,4*(nbl->tab.n+1),16);
   
   for(i=0; i<=nbl->tab.n; i++) {
     for(j=0; j<4; j++)