Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Memory leaks / API-calls
Message
De
06/03/2018 05:07:32
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Titre:
Memory leaks / API-calls
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 10
Application:
Desktop
Divers
Thread ID:
01658554
Message ID:
01658554
Vues:
236
Hi all,

I have a piece of quite useful code, a plain windows-API-based case-sensitive replacement for both getfile and putfile that definitely covers a need here: a light, non-COM-based solution. I do not remember the originator of this code. So I cannot credit the author But I have attached the code base.

This VFP encapsulation of GetOpenFileNameA and GetSaveFileNameA IN comdlg32.dll does the job offering what is needed for a neater get/pufile in VFP in a clean way:
SET PROCEDURE TO api_getfile.prg ADDITIVE
oDialog = CREATEOBJECT("API_dialog")
oDialog.showdialog()
With a hosts of functionality available as clean object properties (file extension choice list and various presentation style and input checks). Only ONE single issue but a serious one: memory leaks!

I understand that encapsulating C/C++ data structures from VFP is a challenge. When I review code with VFP instructions such as:
DECLARE INTEGER GetSaveFileNameA IN comdlg32.dll AS _FFC_SAVEFILENAME STRING @
DECLARE INTEGER GetOpenFileNameA IN comdlg32.dll AS _FFC_GETFILENAME STRING @
DECLARE INTEGER malloc IN msvcrt.dll AS _FFC_MALLOC INTEGER
DECLARE free in msvcrt.dll AS _FFC_FREEMEM INTEGER 
DECLARE INTEGER memcpy in msvcrt.dll AS	_FFC_MEMCPY2 STRING @, INTEGER , INTEGER
DECLARE INTEGER memcpy IN msvcrt.dll AS _FFC_MEMCPY  INTEGER , STRING @, INTEGER
... Well VFP could lose track and memory. It definitely does here!!

Should anyone with an expertise on this stuff VFP-API interop have an idea on how to patch the stuff, you are quite welcome. My last C-coding session; early 1990s on Watcom-VFP integration.... Well that's some years ago. I am certainly leaking memory too! And my early 1990s expertise on the subject is down to nothing:-)

Any pointer on the code attached is welcome.

Regards to you all, Daniel

PS: I am not really looking for a replacement via COM-based solutions or other heavy solutions :-)
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform