Buffered _read and _write... how to get more buffer memory?

J

Jasim

Hi,

I'm a newbie C programmer, and I've written a Buffered File Copy
program in C (which can be considered my rather first acceptable
venture into the bold brave world of C)

I am using faralloc() to get large chunks of memory for my buffer and
even that does not work (for buffer size > 65535). But faralloc() does
not show any problem (ie, does not return null) even when I allocate
527 kb of memory)

I'm using _read and _write functions for file i/o and I doubt whether
they are incapable of using more than this amount of data at a time..

I checked out the product 'Controlled Copy' and even it says it uses
only 48kb buffer.. So, is it some barrier which cannot be broken?

I'm relatively new to C programming ('ve been programming in xBase
languages till..). If the source code of my app would help by any
means, then please do contact me and I'll be sending it...

Thanks in advance,

Regards
Jasim A Basheer
India.

please mail me to : (e-mail address removed) -- replace the domain
name with
hotmail.com
 
P

Peter Pichler

[Posted and mailed.]

Jasim said:
Hi,

I'm a newbie C programmer, and I've written a Buffered File Copy
program in C (which can be considered my rather first acceptable
venture into the bold brave world of C)

I am using faralloc() to get large chunks of memory for my buffer and
even that does not work (for buffer size > 65535). But faralloc() does
not show any problem (ie, does not return null) even when I allocate
527 kb of memory)

faralloc() is not a standard C function. You must be using some older
compiler (in some weird mode, such as DOS 'small' memory model) that
supports this function as an extension.
I'm using _read and _write functions for file i/o and I doubt whether
they are incapable of using more than this amount of data at a time..

_read() and _write() are not standard C functions either.
I checked out the product 'Controlled Copy' and even it says it uses
only 48kb buffer.. So, is it some barrier which cannot be broken?

We don't know. Since all of the functions that you are asking about are
non-standard, you are unlikely to get an answer here. This newsgroup
discusses standard (also called ANSI or ISO) C only.

Having said that, try checking your documentation for the functions you are
using. Given the weird memory model, it is quite possible that you are using
a 16-bit compiler where ints are not big enough to represent your buffer
size. If _read() and/or _write() take int as a parameter, you are in bad
luck. You need to read/write in smaller blocks.
I'm relatively new to C programming ('ve been programming in xBase
languages till..). If the source code of my app would help by any
means, then please do contact me and I'll be sending it...

Thanks in advance,

Regards
Jasim A Basheer
India.

please mail me to : (e-mail address removed) -- replace the domain
name with
hotmail.com

Two things:
1) The rule in comp.lang.c (and generally on Usenet) is, "post here, read
here". Don't ask for email responses.
2) There's no need to unscramble your address, as your "From:" field

This is the only reason I am actually replying to you in an email, or indeed
at all. Your post is off topic, which I suppose you would have known if you
had read a few other posts before posting yours. But I admire your youthful
spirit and enthusiasm, so I will let you off this time ;-)

Peter
 
J

Jasim

Dear Mr. Peter,

We don't know. Since all of the functions that you are asking about are
non-standard, you are unlikely to get an answer here. This newsgroup
discusses standard (also called ANSI or ISO) C only.
Didnt know. Thanks very much for the tip..
Having said that, try checking your documentation for the functions you are
using. Given the weird memory model, it is quite possible that you are using
a 16-bit compiler where ints are not big enough to represent your buffer
size. If _read() and/or _write() take int as a parameter, you are in bad
luck. You need to read/write in smaller blocks.
_read and _write takes long as parameters (in Borland C++ 3.1)
Well, I've figured out a possible solution..
Two things:
1) The rule in comp.lang.c (and generally on Usenet) is, "post here, read
here". Don't ask for email responses. Sorry..

2) There's no need to unscramble your address, as your "From:" field
contains a valid address. If you HATESPAMMERS <g>, scramble that one too.
Actually, that is the address I've left for spammers. I dont usually check that
address, (it might be receiving an MB of spam a day..!)
This is the only reason I am actually replying to you in an email, or indeed
at all. Your post is off topic, which I suppose you would have known if you
had read a few other posts before posting yours. But I admire your youthful
spirit and enthusiasm, so I will let you off this time ;-)
Thanks again for your help.. and advice..

Regards,
Jasim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top