[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: revisiting the ftp_list problem
Sender: Scott Klement <klemscot@xxxxxxxxxxxx>
On Wed, 16 Oct 2002, Richard B Baird wrote:
>
> I hope this is a little better question.
>
> If I pass, say 32767 to ftp_list as the number of entries I want to
> recieve, it will load memory with as many as it finds up to 32767, right?
Yes. Likewise, if you passed 100000, it would load up to that many. The
number is just a limit so that FTP_LIST doesn't overflow the amount of
memory you've given it.
>
> what's to keep me from doing this:
>
> instead of defining an array based on the pointer returned by ftp_list, and
> rolling through it via subscript, I instead have a single based variable
> 256 bytes long, and I increment the basing pointer by 256 to get the next
> occurance of the 'array'?
Nothing is to keep you from doing that... in fact, I designed it the way
that I did so that you could use a dynamic memory allocation or even a
user space if you wanted to make sure you had enough space to get all of
the entries.
Believe it or not, I put a lot of thought into the design of FTP_list :)
>
> is that legal? does it make sense?
It's legal. The one thing that I do want to clarify, however, is that
YOU must allocate the memory that FTP_list will be using. It does not
allocate it for you.
You used the phrase "the pointer returned by FTP_list" and I just want to
make sure we don't have a misunderstanding here. FTP_list does not
return a pointer. You give it an input-only pointer, which it uses to
determine where to store the entries returned from the server.
If you decide to use a pointer, and you wish to allow FTP_list to return
up to 32767 entries, then you must allocate 256 * 32767 bytes for FTP_list
to use with the ALLOC op-code. And you must call DEALLOC when you're
done with that memory.
As long as you do that, your method will work nicely.
-----------------------------------------------------------------------
This is the FTPAPI mailing list. To unsubsribe from the list send mail
to majordomo@xxxxxxxxxxxxx with the body: unsubscribe ftpapi mymailaddr
-----------------------------------------------------------------------