Skip to Content
우아한 C언어 코딩 패턴
book

우아한 C언어 코딩 패턴

by Christoper Preschem, 정기훈(Jung Ki Hun)
April 2024
Beginner to intermediate
364 pages
7h 2m
Korean
Insight
Content preview from 우아한 C언어 코딩 패턴
C
95
󼨯󺟈󽴔󺱧󼡋
󼨯󺟈󽴔󺱧󼡋
󼎷󼘜󻝳󼞇
코드의 여러 위치에서 동적 메모리를 할당하고, 메모리 부족과 같은 오류 상황
에 대응하려 한다.
󻀇󻳫
󻪇󻳫󺦯󻺏󽴔󺢨󻳐󽴔󺼣󺽷󺹻󽴔󼨯󺟈󻱃󽴔󻞳󼟷󼨯󽴔󻛧󽴔󻱗󻰋󻂏󺴫󻱃󻪟󽴔󺟏󻰠󼨧󺋿󽴔󻯓󼩃󻗫󺝣󽴔󼐣󺦫󻪟󻗫󽴔󻱋
󻱋󻱃󽴔󼨯󺟈󽴔󺅿󺇋󺹋󽴔󼬤󻱇󼩃󻩋󽴔󼨫󺞳󼐣󺦫󽴔󺖃󽴔󻱃󺇂󻳏󺇂󻪟󻗫󽴔󻱃󺲻󼨫󽴔󺅏󻕻󺹋󽴔󼩃󻩋󽴔󼨧󺝣󺠿󻱃
󺅒󻰏󽴔󺐳󺕧󽴔󻘀󺃏󻞯󽴔󻱋󻱃󺞳
요청한 메모리를 사용할 수 없으면
malloc
함수는
NULL
을 반환한다.
malloc
의 반환 값을 확인하지 않으면 메모리를 사용할 수 없고
NULL
포인터에 접근하
는 경우에 프로그램이 충돌을 일으킬 수 있다. 메모리를 할당받은 모든 곳에서
반환 값을 점검한다면 코드는 더 복잡해지고, 읽고 유지󱌒관리하기도 더 힘들어
진다.
이러한 점검 지점이 코드베이스 전체에 퍼져 있는 상태에서 추후에 할당 오
류 시에 취하는 동작을 수정하려면 여러 위치에서 코드를 수정해야 한다. 기존
함수에 오류 점검 코드를 추가하면, 하나의 함수는 하나의 역할만 수행해야 한
다는(그리고 할당이나 프로그램 로직 같이 여러 가지를 동시에 수행하면 안 된
다는) 단일 책임 원칙을 위반하게 된다.
또한, 명시적으로 할당받은 모든 메모리를 초기화하기 위해 나중에 메모리
할당 방법을 바꾸려 하면 코드 여기저기에 퍼져 있는 할당 함수들을 많이 호출
하게 되고 작업이 매우 어려워진다. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

파이썬으로 살펴보는 아키텍처 패턴

파이썬으로 살펴보는 아키텍처 패턴

오현석, 해리 퍼시벌, 밥 그레고리
클라우드 네이티브 애플리케이션 디자인 패턴

클라우드 네이티브 애플리케이션 디자인 패턴

카순 인드라시리, 스리스칸다라자 수호티얀
개발 7년차, 매니저 1일차

개발 7년차, 매니저 1일차

권원상, 한민주, 카미유 푸르니에

Publisher Resources

ISBN: 9788966264742