Re: [Dev-C++] What is a static function
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Vassili <v.v...@bt...> - 2001-08-03 02:41:03
|
If you do use malloc in a function then you should return the pointer
(unless you free the memory in the function).
You see, once the function is finished with, it's basically destroyed and
you will have memory allocated but with nothing connecting it. When you call
the function again it allocates more memory, and slowly, slowly you chew
your memory away.
This is basically oop, you create an object, then you destroy it.
best of luck
Vas.
----- Original Message -----
From: "Albert Vilella Bertran" <vil...@ya...>
To: <dev...@li...>
Sent: Thursday, August 02, 2001 1:47 PM
Subject: [Dev-C++] What is a static function
> I don't understand what is like to declare a function as "static".
> For example:
>
> static void initBV() {
> if (!inittedBV)
> {
> int i;
> for (i=0; i<ArraySize(bV); i++)
> bV[i] = -1;
> bV['a'] = bV['A'] = A_B_V;
> bV['b'] = bV['B'] = B_B_V;
> bV['c'] = bV['C'] = C_B_V;
> bV['d'] = bV['D'] = D_B_V;
> bV['e'] = bV['E'] = E_B_V;
> inittedBV = TRUE;
> }
> }
>
> What is that code doing?
> If I "malloc" something inside the function, what happens? Is the space
> able to be freed outside of the function?
> How is that "int i" variable managed, is it created always but not used
> unless the "if" condition is true?
> Can I put this kind of conditional declaration of functions in a
non-static
> function?
>
> I don't know much of it, you see! :)
>
>
> _______________________________________________________________
> Do You Yahoo!?
> Yahoo! Messenger: Comunicación instantánea gratis con tu gente -
> http://messenger.yahoo.es
>
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> http://lists.sourceforge.net/lists/listinfo/dev-cpp-users
|