Cast ptr/len to D-style array
    ag0aep6g 
    anonymous at example.com
       
    Thu May  2 20:05:33 UTC 2019
    
    
  
On 02.05.19 22:03, James Blachly wrote:
> I work a lot with C functions, many of which yield pointer + length.
> 
> Is there a way to cast this or materialize a D-style array backed by the 
> already allocated data (with length) to avoid copies which slow things 
> down?
Just slice the pointer with the length:
     int* ptr;
     size_t len;
     int[] arr = ptr[0 .. len];
    
    
More information about the Digitalmars-d-learn
mailing list