Changeset 268:5995c228c72f

Show
Ignore:
Timestamp:
07/06/08 09:35:58 (3 months ago)
Author:
Frank Benoit <benoit@tionex.de>
branch:
default
Message:

Fix: string termination

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • dwt/dnd/FileTransfer.d

    r259 r268  
    6767 * Each <code>String</code> in the array contains the absolute path for a single 
    6868 * file or directory. 
    69  *  
     69 * 
    7070 * @param object a java <code>String[]</code> containing the file names to be converted 
    7171 * @param transferData an empty <code>TransferData</code> object that will 
    7272 *      be filled in on return with the platform specific format of the data 
    73  *  
     73 * 
    7474 * @see Transfer#nativeToJava 
    7575 */ 
     
    122122 * @return a java <code>String[]</code> containing a list of file names if the conversion 
    123123 *      was successful; otherwise null 
    124  *  
     124 * 
    125125 * @see Transfer#javaToNative 
    126126 */ 
     
    134134            int size =  i - offset; 
    135135            char* file = cast(char*)OS.g_malloc(size + 1); 
    136             String fileBuffer = new char[size + 1]; 
    137             System.arraycopy(temp, offset, fileBuffer, 0, size); 
    138             file[ 0 .. size + 1 ] = fileBuffer; 
    139             char*[] newFiles = new char*[files.length + 1]; 
    140             SimpleType!(char*).arraycopy(files, 0, newFiles, 0, files.length); 
    141             newFiles[files.length] = file; 
    142             files = newFiles; 
     136            file[ 0 .. size ] = temp[ offset .. offset+size ]; 
     137            file[ size ] = '\0'; 
     138            files ~= file; 
    143139            offset = i + 2; 
    144140        } 
     
    147143        int size =  temp.length - offset; 
    148144        char* file = cast(char*)OS.g_malloc(size + 1); 
    149         String fileBuffer = new char[size + 1]; 
    150         System.arraycopy(temp, offset, fileBuffer, 0, size); 
    151         file[ 0 .. size+1 ] = fileBuffer; 
    152         char*[] newFiles = new char*[files.length + 1]; 
    153         SimpleType!(char*).arraycopy(files, 0, newFiles, 0, files.length); 
    154         newFiles[files.length] = file; 
    155         files = newFiles; 
     145        file[ 0 .. size ] = temp[ offset .. offset+size ]; 
     146        file[ size ] = '\0'; 
     147        files ~= file; 
    156148    } 
    157149    String[] fileNames;