Re: Programming in standard c




"user923005" <dcorbit@xxxxxxxxx> schreef in bericht news:893ebc34-1590-46cd-88fb-29795311d2b5@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Dec 28, 4:32 am, Chris Torek <nos...@xxxxxxxxx> wrote:
In article <eaednRrgxJMrC-7anZ2dnUVZ8h2dn...@xxxxxx>

Malcolm McLean <regniz...@xxxxxxxxxxxxxx> wrote:
>/*
> function to slurp in an ASCII file
> Params: path - path to file
> Returns: malloced string containing whole file
>*/

I think we can improve this a great deal, with the result being
a function that is written entirely in Standard C and works in
every case in which it is possible for it to work, and -- by
calling a system-dependent function that the user is to supply,
but which may be replaced with a #define that simply returns 0
if desired -- is "reasonably efficient" as well.
[snip]

I work for a database company, and most of our customers are large
customers. (E.g. huge US company, large university, government of
country x, etc.)

It is not at all unusual for a single file to be 20-100 GB. Needless
to say, you would not want to put this file into memory even if you
could do it.
The files I work with are also being modified constantly (though there
are occasionally windows of inactivity for some of them).
I am quite sure that the goal of reliably reading these sorts of files
into memory and doing something useful with them is literally
infeasible (not impossible, but the cost would make it so stupid that
nobody would want to do it).



What is your point? This DBMS doesnt come with an API to update the database? You have to use fread to get records? Surely not. The reasons for not including a function like filesize in the standard are getting funnier by the minute.

There are BTW more uses for a filesize function than just get the size to malloc memory with. How about for your DBMS and you want to create an administration tool where you can constantly monitor how big the files are. Just an extra thingie you would be able to do in standard C.

This is really getting silly, a function like filesize could be put into the standard and it would be useful. But as pointed out elsewhere in this thread this discussion wont help to get the function into it.

.



Relevant Pages

  • Re: A solution for the allocation failures problem
    ... Can you find anything in the standard which *allows* this behaviour? ... it defines how your C program is supposed to behave. ... previously allocated memory available for further allocation. ... says the memory will be made available for further allocation. ...
    (comp.lang.c)
  • Re: Target market for Intellasys.
    ... I would like to see a full speed general purpose embedded serial interconnect IO bus standard. ... Looking through serial memory I found something like a maximum of 70mhz speed which is pretty useless if it was the only bus in a cutting edge design. ... All other control mode levels also have this ability, to allow developer to instigate their own versions of the features not defined in that level, as they wish, if they wish. ...
    (comp.lang.forth)
  • Re: Copying pthread_t
    ... Where is this different from all the other functions in the standard? ... object is modified through one pointer while the other pointer is ... each 'pthread_t' could have some memory allocated to ... initialize a pthread_t is by one of the pthread_* functions like ...
    (comp.programming.threads)
  • Re: close fd while select/poll/epoll
    ... |> does the closing of the descriptor until after the select/poll. ... If the kernel conforms to a standard I have in mind, ... get EBADF if the descriptor is already closed by the time pollenters ... suppose we allocate more memory than the system has. ...
    (comp.os.linux.development.system)
  • Re: Why no folder manipulation in Std C
    ... obeys every other requirement laid out in the standard. ... correctly execute the "one program" doesn't guarantee anything about ... implementation creates machine code for the "one program" that attempts ... platform which doesn't have enough memory to allow such an object to be ...
    (comp.std.c)