Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » What is OF used for?

This thread is locked; no one can reply to it. rss feed Print
What is OF used for?
Doctor Cop
Member #16,833
April 2018
avatar

I found this piece of code at GitHub and i wondered what it might be for, then I Googled "What is OF used for in C?". Did I searched it wrong?

#ifdef Z_SOLO

void *myalloc OF((void *, unsigned, unsigned));
void myfree OF((void *, void *));

void *myalloc(q, n, m)
    void *q;
    unsigned n, m;
{
    (void)q;
    return calloc(n, m);
}

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Peter Hull
Member #1,136
March 2001

It's part of zlib, isn't it?
https://github.com/madler/zlib/blob/cacf7f1d4e3d44d871b605da3b647f07d718623f/zconf.h.in#L288-L294

It's used here to declare a function with or without types. If STD_C is defined you will get

void *myalloc (void *, unsigned, unsigned);
void myfree (void *, void *);

otherwise

void *myalloc ();
void myfree ();

The first is correct for all modern C compilers (that is, more recent than the 1980s probably!) whereas older compilers used the second form.

So, the overall purpose is for compatibility.

Doctor Cop
Member #16,833
April 2018
avatar

Thanks Peter, yes it's of zlib.
I'm struggling through examples cause I couldn't find any tutorials.

Niunio
Member #1,975
March 2002
avatar

It is a bit off-topic but there were years that I didn't see good ol' K&R C code.

void *myalloc(q, n, m)
    void *q;
    unsigned n, m;
{
    (void)q;
    return calloc(n, m);
}

-----------------
Current projects: Allegro.pas | MinGRo

Go to: