Jeff Bailey on 5 Oct 2018 14:37:34 -0700


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Anyone Experienced with C Pointers?


I'd say that you have a basic understanding of memory allocation, but that's not really the same as asking about C pointers.

The stack is used for statically allocated memory - things like declared variables, function parameters, etc.

The heap is used for dynamically allocated memory - this memory is allocated at run-time - calls like malloc and calloc are allocating memory from the heap.  This might be used when a variable's size is not known at compile-time (IE: an array of some sort whose capacity is based off of some kind of input).

When you allocate memory from the heap, you'll get a pointer (an address) back to that memory. You then access that memory through operations on that pointer.

This is all pretty high level - does it answer your question at all?


-----Original Message-----
From: Ron Guilmet <ronpguilmet@gmail.com>
To: Philadelphia Linux User's Group Discussion List <plug@lists.phillylinux.org>
Sent: Fri, Oct 5, 2018 5:19 pm
Subject: [PLUG] Anyone Experienced with C Pointers?

I have been working with writing a device driver for my HP laptop. The
wireless doesn't work well. I think it is an antenna selection issue.
The laptop any distro shows about 10% on the wifi even when you are 10
feet away.

That said, I've been refreshing myself with C. Pointers is one of those
areas that seem to give everyone a hard road to hoe. Sometimes a high
overview helps. I wanted to present what my understanding is, and I was
hoping someone could elaborate on it.

My understanding of pointer use is the following. I understand there
are different sections of memory. A section for the code, a section for
the running app called the stack, and then your free or available
memory called the heap. I understand that if the running program needs
more memory, it has to access the heap, and the heap can only be
addressed by memory addresses. Does that sound about right?

Rom

___________________________________________________________________________
Philadelphia Linux Users Group        --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --  http://lists.phillylinux.org/mailman/listinfo/plug
___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug