Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation on 08/31/22 in all areas

  1. Remy Lebeau

    Getting of dynamic array from Variant

    By default, an array inside a Variant is stored as (a pointer to) a COM SAFEARRAY: https://docs.microsoft.com/en-us/archive/msdn-magazine/2017/march/introducing-the-safearray-data-structure https://docs.microsoft.com/en-us/windows/win32/api/oaidl/ns-oaidl-safearray Which is completely different than a Delphi-style dynamic array. The two are not compatible with each other. The only way to store a Delphi-style dynamic array AS-A dynamic array in a Variant is to use a custom Variant type: https://docwiki.embarcadero.com/RADStudio/en/Defining_Custom_Variants That being said, Delphi 10.2 and later are more strict about NOT letting you assign a raw Pointer to a dynamic array, as you are trying to do: So, you would have to type-cast the raw Pointer in order to get the old Delphi 6 behavior, eg: type TDoubleArray = array of double; var Value: Variant; //this variable is assigned to a dynamic array somewhere in the code ... procedure DoSomething; var rv: TDoubleArray; begin rv := TDoubleArray(TVarData(Value).VArray.Data); // note, no @ used here. Why would you want to assign a PPointer to a dynamic array??? ... end; But, it never made sense to me why anyone would ever want to do this, since this makes the dynamic array point at something that is not a valid dynamic array, and can't be accessed as a dynamic array. The structure of a SAFEARRAY and a dynamic array are completely different. In any case, to safely access the raw data of a SAFEARRAY, you MUST use the SafeArrayAccessData() function, which Delphi's RTL has wrapped in the VarArrayLock() function, eg: var Value: Variant; //this variable is assigned to a dynamic array somewhere in the code ... procedure DoSomething; var rv: PDouble; begin rv := PDouble(VarArrayLock(Value)); try // use rv as needed... finally VarArrayUnlock(Value); end; end;
  2. You really, really, REALLY don't want to expose direct DB queries to your database. A proper scalable and securable REST frontend is a must, IMO - unless it is some basement hobbyist project.
  3. dummzeuch

    wuppdi import

    Apart from restarting the IDE, File -> Favorite File Collection -> Open Default Collection also works. Yes, calling AddChildObject fixes the problem. Sorry, I missed that.
  4. baka0815

    wuppdi import

    Ok, I hope I addressed all issues. I created a new form to select the WuppdiWP configuration file as well as a subfolder. The default is "WuppdiWP" and an empty subfolder means "overwrite existing favorites". The user get's an appropriate message. Otherwise the new subfolder is created and the the configuration file is read into that. I didn't touch any of the project files as I only have Delphi 11 and I didn't want to break any existing project files and was unsure adding the new unit with a text editor or similar. I can still do that if you want. But it was enough of a hassle to create the new form completely in Notepad++ to not include some Delphi 11 specialities. FavoriteFiles.patch
  5. I'm not sure what you are saying here. Writing to memory is just writing to memory. Be it some intermediate buffer or the memory block backing the stream. Can you explain what performance block you are trying to overcome. Reallocation is the only block I can see.
  6. Rangga

    SqllocalDB

    for more detail, you can refer here : https://docwiki.embarcadero.com/RADStudio/Sydney/en/Connect_to_Microsoft_SQL_Server_(FireDAC)
  7. What exactly is the problem you want to solve? Reallocating memory when writing to TMemoryStream?
  8. I made a simple wrapper for libdeflate and test its speed compared to default Delphi Zip library. Test performs compression and decompression of 1Mb XML file. Libdeflate is 3.4 times faster than Delphi ZLib (Delphi 11, Win64).
  9. Rather than buffering in this case I have a memory stream that doesn't use contiguous memory. Instead of a single memory block, it manages a list of equally sized blocks. This avoids any performance issues with repeated calls to ReallocMem. Is that the performance block you want to work around?
×