메모리,memory상의 위치를 가리키는 변수인가 아님 그런 변수의
형,type(
타입,type으로 pagename determined.)인가?
{
메모리
- 할당 - malloc
- 해제 - free
- 누수
- 포인터
- 주소
메모리 관련
C언어 함수
함수 | 원형 | 하는 일 | 리턴값 |
memset | void *memset(void *str, int c, size_t n) | memset(위치, 값, 크기). 위치에 값을 크기만큼 채우기 | str (이것 관련해서 hn에서 논쟁이 있었는데..TBW) |
memcpy |
memccpy | void *memccpy(void *dest, const void *src, int c, size_t n); | src에서 dest로 n바이트 복사하며 도중에 문자 c를 만나면....TBW |
memmove |
memchr | | 메모리에서 문자 찾기 |
memcmp |
memicmp | | 대소문자 구분없이 비교 |
}
Sub:
포인터산술,pointer_arithmetic { 덧셈은 의미가 없고
뺄셈,subtraction은
주소,address 메모리주소,memory_address의 차이이고, 등등.
포인터,pointer 산술,arithmetic }
널포인터,null_pointer -
널,null
포인터분석,pointer_analysis
}
garbage_collection
reference -
참조,reference
=참조,reference =,reference .
{
포인터,pointer가
참조,reference를 하려면, 대상의
주소,address esp
메모리주소,memory_address가 필요?
포인터가 값을 갖는(포인터에 주소를
대입,assignment하는) 것 ≡ 포인터가 대상/target/
객체,object를 가리키는 것?
*가 typename에 붙는가, variable name에 붙는가에 대한 convention도 있는데 나중에.
2. 포인터 연산자 pointer operator ¶
C의 경우
++, -- 에 대해선 아래 포인터의 증감 section에
3. 포인터의 증감 ¶
C의 경우
포인터에 증감(증가 increment ++ 감소 decrement --) 연산을 하면, 그 값이 하나씩 변하는 것이 아니라 (포인터가 가리키는 type?)의 size만큼 증감.
4. 포인터와 배열 ¶
C의 경우 다음 둘이 equivalent
*(arr+i)
a[i]
이건 syntactic_sugar ?
5. 포인터와 문자열 ¶
C에선 따로 문자열
형,type이 없고
char*
을 문자열형처럼 쓰는데..
이것도 syntactic_sugar ?
7. Dangling pointer ¶
AKA 미결합 포인터, 댕글링 포인터, 허상 포인터(WpKo), 와일드 포인터(wild pointer)
Ex.
#include <stdio.h>
void func(int *p) {
int b = 10;
p = &b;
printf("*p = %d\n", *p);
}
int main() {
int *a;
func(a);
printf("*a = %d\n", *a);
}
8. void 포인터 (C) ¶
int main()
{
int i = 0;
float f = 1.0f;
void *p;
p = &i;
*(int *)p = 2;
p = &f;
*(float *)p = 3.0f;
}
9. near/far 포인터 (16bit IBM PC) ¶
16비트 환경에서는 far 포인터 관련 함수가
malloc | farmalloc |
calloc | farcalloc |
realloc | farrealloc |
memset | _fmemset |
등의 near와 다른 별도의 함수로 분리되어 있음.
매크로
{
MK_FP(seg, ofs)
16비트 segment와 offset을 받아 far pointer를 만들어 줌
FP_SEG(fp)
far pointer에서 세그먼트 추출
FP_OFF(fp)
far pointer에서 오프셋 추출
}
10. smart pointer (C++ etc) ¶
12. thin/fat ¶
thin_pointer
fat_pointer
thin pointer
fat pointer
tagged
tagged pointer
tagged_pointer