메모리를 그릴때 어떻게 표현해야 하는지요?

KLDP87의 이미지

생각만 하던걸 막상 표현 하려고 하니까 머뭇거리게 되는데 뭔가 예제 같은게 있는지 궁금해서

첨부파일에 제가 그냥 그린것들을 올려봅니다;;

추가로 realloc같은 경우는 malloc으로 할당을 먼저 하고 변경하라고 하던데 단독으로 사용해도 되는지도 궁금합니다.

많은 조언 부탁드립니다.

감사합니다.

File attachments: 
첨부파일 크기
Image icon struct.JPG53.81 KB
snowall의 이미지

메모리 관련 그림이네요

https://encrypted.google.com/search?q=memory+map&hl=ko&tbo=u&tbm=isch&source=univ&sa=X&ei=bF_1UKzPFsbGkAX3jIHQBg&ved=0CEMQsAQ&biw=1760&bih=939

그리고 realloc은 '다시 할당'하는 함수니까, 그 전에 할당이 되어 있어야겠죠?

피할 수 있을때 즐겨라! http://melotopia.net/b

KLDP87의 이미지

그 할당을 한다는 의미가 꼭 malloc이나 calloc만 할당해서 사용할 필요는 없다는 뜻으로 이해해도 되는건가요?

링크 감사합니다. 제가 그린것과 비슷하네요 ㅎ;

snowall의 이미지

당연히 malloc이나 calloc으로 할당한 다음에 쓰라는 뜻이죠.

http://forum.falinux.com/zbxe/?document_srl=408159

피할 수 있을때 즐겨라! http://melotopia.net/b

february28의 이미지

간만에 손좀 풀어 봤습니다.
올리신 그림의 의도가 불분명한것도 있지만, 나름 해석 해서 그려봤습니다.

댓글 첨부 파일: 
첨부파일 크기
Image icon pointer_memory_draw.PNG10.09 KB

--------------------------------------------------------------------------------
open source, open teaching, 천기누설이 꿈~ 은 개뿔...
--------------------------------------------------------------------------------

raymundo의 이미지

"단독으로 사용"이라는 말뜻이 뭐냐에 따라 다른데,

realloc(ptr, size) 이렇게 호출할 때,
1) ptr == NULL 인 상태로 호출하면 malloc 처럼 동작하니 괜찮습니다.
2) ptr != NULL 인 경우에는 반드시 ptr 값이 기존에 malloc, calloc, 또는 realloc 에 의해 반환된 값이어야 합니다.
단 ptr 에 뚱딴지 같은 주소가 들어 있는 상태에서 호출하면 그건 곤란한 거죠.

man realloc:
  If ptr is NULL, the call is equivalent to malloc(size);
  Unless ptr is NULL, it must have been returned by an earlier call to malloc(), calloc() or realloc().

좋은 하루 되세요!

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.