malloc error when trying to assign the returned pointer to a struct field
    Brad Roberts 
    braddr at puremagic.com
       
    Sat Sep  9 08:54:14 UTC 2023
    
    
  
On 9/8/2023 12:59 AM, rempas via Digitalmars-d-learn wrote:
> u64 _cap = 0;   // Total amount of elements (not bytes) we can 
> this._ptr = cast(T*)malloc(size);
I'm pretty sure this is your problem.  You're allocating size bytes 
which is only going to work where sizeof(T) == 1.  Changing to 
malloc(size * sizeof(T)) is likely going to work better.
    
    
More information about the Digitalmars-d-learn
mailing list