{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

EECS 280 Discussion.week10

EECS 280 Discussion.week10 - EECS 280 Discussion#10 Memory...

Info iconThis preview shows pages 1–10. Sign up to view the full content.

View Full Document Right Arrow Icon
EECS 280 Discussion #10 Memory Issues and Debugging
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Pointer Initialization What happens if the following code is run: int * p; *p+=1;
Background image of page 2
Pointer Initialization What happens if the following code is run: int * p; *p+=1; BEST CASE: SEGFAULT (?)
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Pointer Initialization What happens if the following code is run: int * p; *p+=1; BEST CASE: SEGFAULT (?) WORSE CASE: UNDEFINED BEHAVIOR
Background image of page 4
Pointer Initialization What happens if the following code is run: int * p = NULL; *p+=1; EVERY CASE: SEG FAULT
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
NEW CONCEPT: SEGFAULTS ARE GOOD Seg faults aren’t generally very fun, but…
Background image of page 6
NEW CONCEPT: SEGFAULTS ARE GOOD Seg faults aren’t generally very fun, but…it is SO MUCH BETTER to have a seg fault early in your code than have an undefined behavior
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
NEW CONCEPT: SEGFAULTS ARE GOOD Seg faults aren’t generally very fun, but…it is SO MUCH BETTER to have a seg fault early in your code than have an undefined behavior Thus: int * p; //BAD int * p = NULL; //BETTER!
Background image of page 8
Whoa… back up… What’s ‘NULL’?
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 10
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}