Skip to main content

Thread: globals


this noob question, oh well.

i've read somewhere globals best defined on stack. that's nice , all, how when have large resources (image files, etc.) you'd rather global parts of program , can't defined on stack? can define pointer on stack in 1 file have others have extern in other files, yes, actual data on heap.

how problem? unless sloppy?

know send address of said resources each , every function in other files uses them, , conscious you're sending who, makes things more cumbersome, having make long arrays of pointers resources, example, when defining them global, , being careful, do.

thanks.

quote posted noobermin view post
that's nice , all, how when have large resources (image files, etc.) you'd rather global parts of program , can't defined on stack? can define pointer on stack in 1 file have others have extern in other files, yes, actual data on heap.
you're given relatively small amount of memory on stack work with, whereas amount of heap space you're allowed request scales amount of available memory. thus, big things go on heap, , small local things go on stack.

how problem? unless sloppy?
you run risk of corrupting stack. taking random global may or may not know size of , manipulating asking buffer overflow. it's not big of deal on small projects 1 person doing of coding, , know details of implementation.


Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk globals


Ubuntu

Comments

Popular posts from this blog

CS5 Adobe Media Encoder: Encode failed because the source duration is nil.

cf_sql_integer vs cf_sql_bigint vs cf_sql_int??

localhost/joomla15/administrator doesnt work - Joomla! Forum - community, help and support