포인터,pointer

메모리,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 대소문자 구분없이 비교

}



LINKTHESE:
주소,address
메모리_관리,memory_management ... 보단 메모리관리,memory_management
MMU
메모리_할당,memory_allocation ... 보단 메모리할당,memory_allocation
동적_메모리_할당,dynamic_memory_allocation ...보단 동적메모리할당,dynamic_memory_allocation
{
할당받은 메모리는 사용이 끝나면 해제(free)해야 함.
C언어는 수동 해제해야 하 며,
garbage collection을 지원하는 언어는 사용되지 않는 메모리를 자동으로 해제함.
동적 메모리를 해제하지 않아서 가용 메모리가 줄어드는 현상은 memory_leak.

}
garbage_collection
reference - 참조,reference
=참조,reference =,reference .
{
포인터,pointer참조,reference를 하려면, 대상의 주소,address esp 메모리주소,memory_address가 필요?
포인터가 값을 갖는(포인터에 주소를 대입,assignment하는) 것 ≡ 포인터가 대상/target/객체,object를 가리키는 것?

self-reference
자기참조?
자신참조?
(VG "self-reference"을(를) 전체 찾아보기 => http://tomoyo.ivyro.net/123/wiki.php/FindPage?action=fullsearch&value=self-reference&context=20&case=1 )
{
https://en.wikipedia.org/wiki/Self-reference
... Google:self-reference
}


WpKo:참조
WpEn:Reference_(computer_science)
}
referencing a pointer
dereference
{
}
call_by_reference { 참조,reference 호출,call }
reference_counting =,reference_counting . reference_counting
{
참조,reference counting 셈/세기/...
https://ko.wikipedia.org/wiki/참조_횟수_계산_방식
https://en.wikipedia.org/wiki/Reference_counting
REL: memory_management > garbage_collection
}
memory_leak




1. 포인터란

주소,address(esp 메모리,memory메모리주소,memory_address)를 담는 변수,variable.
i.e.
포인터에 들어가는 값은 메모리 주소. 메모리상의 어떤 위치.

보통 machine의
워드,word size (word_size)
또는 레지스터,register size (register_size)
에 따른?

C에서 선언은
char *i;
int *j;

*가 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 ?

6. 이중 포인터

이중포인터가 가리키는 곳을 참조하려면
**p

7. Dangling pointer

AKA 미결합 포인터, 댕글링 포인터, 허상 포인터(WpKo), 와일드 포인터(wild pointer)

dangling_pointer
rel.
dangling_reference - 존재하지 않는 것에 대한 참조,reference?


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)

보통 도스,DOS에서 씀
(Win16에서는?) windef.h에 정의되는데 Win32로 바뀌면서 빈 문장으로 처리하도록 변경됨.

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)

smart_pointer
=,smart_pointer . smart_pointer
https://en.wikipedia.org/wiki/Smart_pointer

10.1. auto_ptr (C++)

"The C++11 standard made auto_ptr deprecated, replacing it with the unique_ptr class_template. auto_ptr was fully removed in C++17"(we)
https://en.wikipedia.org/wiki/Auto_ptr

12. thin/fat

thin_pointer
fat_pointer


thin pointer
fat pointer

13. bounded

bounded pointer
bounded_pointer
https://en.wikipedia.org/wiki/Bounded_pointer