Pointers - scope and lifetime

  Рет қаралды 1,615

Siemens Embedded

Siemens Embedded

Күн бұрын

Пікірлер: 11
@mironovtt
@mironovtt 4 жыл бұрын
You are doing great job! Keep it up, sir! 👍👍👍
@kolhatkarchinmay
@kolhatkarchinmay 4 жыл бұрын
Good Example of Dangling pointer. Collin please upload similar concept video for malloc, calloc and free functions.
@AtAGlimpse_UB
@AtAGlimpse_UB 3 жыл бұрын
I just want to say one thing. Whenever your Microcontroller gets into the infinite loop when you step up your code, that might be due to the pointer pointing to a address which is not existing.
@asafcohen3562
@asafcohen3562 4 жыл бұрын
This is great
@1willFALL
@1willFALL 4 жыл бұрын
Could you do a video on function pointers and maybe also on FILE I/O?
@rafalzasada8826
@rafalzasada8826 4 жыл бұрын
If malloc() returns just a pointer how program know what amount of memory is allocated and can't be used for anything else? The same goes for free() function - if we pass just a pointer to it how program knows what amount of memory became available ? Pointer is just a pointer, sizeof(*p) does not work so where is that information stored about a size?
@leviengel
@leviengel 6 ай бұрын
When using malloc. you basically request the amount of memory you need, the OS, look for that amount of memory in the HEAP region of RAM and if found the amount of memory requested, returns a pointer to the start of that chunk of memory. It is the responsability of the programer to manage and keep track of that memory. That's why when using malloc you have to cast that pointer to the size of datatype you will be using. If malloc does not find the amount of memory you require, it will return a NULL pointer. A pointer has metadata containing information of the size of memory it points to, that's how the OS knows how much memory free.
@muhammadinamulhaq3622
@muhammadinamulhaq3622 4 жыл бұрын
I've a question. If I return the address of array from a function, and use this code x = *(p+3); will it return the right element at that location? or system might use that memory to change the contnts and I might get a wrong value stored in that memory?
@kolhatkarchinmay
@kolhatkarchinmay 4 жыл бұрын
No it will cause segmentation falut. As memory location assigned to arr[ ] is already removed out of stack. So p already containing invalid location. So doing any operation with p is invalid.
@muhammadinamulhaq3622
@muhammadinamulhaq3622 4 жыл бұрын
@@kolhatkarchinmay but p has a memory address and I'm pointing to some value at address *(p+3) so it should be valid. Question is if the data Will be same or as the arr is not there anymore and we've not used malloc so the system might usw the memory and put some other data.
@joaquinortiz279
@joaquinortiz279 4 жыл бұрын
@@muhammadinamulhaq3622 as before mentioned, it will cause a segmentation fault. Don't worry about the data value when you are pointing to undefined memory addresses
you will never ask about pointers again after watching this video
8:03
Dynamic memory in real time systems - a solution?
6:30
Siemens Embedded
Рет қаралды 3,1 М.
99.9% IMPOSSIBLE
00:24
STORROR
Рет қаралды 31 МЛН
Мен атып көрмегенмін ! | Qalam | 5 серия
25:41
Multicore - technology and terminology
5:41
Siemens Embedded
Рет қаралды 1,6 М.
C++ exception handling
5:35
Siemens Embedded
Рет қаралды 3,8 М.
Master Pointers in C:  10X Your C Coding!
14:12
Dave's Garage
Рет қаралды 347 М.
I Spent 100 Hours Inside The Pyramids!
21:43
MrBeast
Рет қаралды 38 МЛН
REFERENCES in C++
10:13
The Cherno
Рет қаралды 599 М.
Selecting an embedded CPU
4:58
Siemens Embedded
Рет қаралды 1,4 М.
What are double pointers in C?
14:43
CodeVault
Рет қаралды 46 М.
Writing Code That Runs FAST on a GPU
15:32
Low Level
Рет қаралды 584 М.
POINTERS in C++
16:59
The Cherno
Рет қаралды 1 МЛН
RISC-V - the latest embedded fashion
5:46
Siemens Embedded
Рет қаралды 1,7 М.
99.9% IMPOSSIBLE
00:24
STORROR
Рет қаралды 31 МЛН