Home > Back-end >  Printf buffer
Printf buffer

Time:06-09

Printf buffer in the heap, or in the stack? The user space and kernel space?

CodePudding user response:

Heap
The user space

CodePudding user response:

reference 1st floor lin5161678 response:
of
The user space
how to prove

CodePudding user response:

Look at the CRT source is not just a matter of,

CodePudding user response:

reference apkipa1 reply: 3/f
see CRT source is not just a matter of,
oh, forgot to say on Linux, CRT is Microsoft, on Ubuntu, or you have online?

CodePudding user response:

reference qiushui, 4/f, qiushui response:
Quote: refer to the third floor apkipa1 response:
see CRT source is not just a matter of,
oh, forgot to say on Linux, CRT is Microsoft, on Ubuntu, or you have online?

The glibc source code search on the net, or do you want to see other versions of the C run-time library code, too,

CodePudding user response:

reference 5 floor apkipa1 reply:
Quote: reference qiushui, 4/f, qiushui response:

Quote: refer to the third floor apkipa1 response:
see CRT source is not just a matter of,
oh, forgot to say on Linux, CRT is Microsoft, on Ubuntu, or you have online?

The glibc source code search on the net, or do you want to see other versions of the C run-time library code, too,
https://code.woboq.org/userspace/glibc/stdio-common/vfprintf-internal.c.html
Line 2299, there was a 8192 - byte array buf, this is about the buffer on the stack?

CodePudding user response:

They read the source code

refer to the second floor in qiushui ah qiushui response:
Quote: refer to 1st floor lin5161678 response:
of
User space
how to prove that

CodePudding user response:

o f qiushui reference qiushui response:
Quote: refer to the fifth floor apkipa1 reply:
Quote: reference qiushui, 4/f, qiushui response:

Quote: refer to the third floor apkipa1 response:
see CRT source is not just a matter of,
oh, forgot to say on Linux, CRT is Microsoft, on Ubuntu, or you have online?

The glibc source code search on the net, or do you want to see other versions of the C run-time library code, too,
https://code.woboq.org/userspace/glibc/stdio-common/vfprintf-internal.c.html
Line 2299, there was a 8192 - byte array buf, this is about the buffer on the stack?
just because that's not the printf buffer

Printf buffer _IO_default_doallocate function distribution inside the
 int 
_IO_default_doallocate (fp) FILE *
{
Char * buf.
Buf=malloc (BUFSIZ);// heap memory
If (__glibc_unlikely (buf==NULL))
return EOF;
_IO_setb (fp, buf, buf + BUFSIZ, 1);
return 1;
}


Call _IO_setb save in FILE members _IO_buf_base
 
Void
_IO_setb (FILE * f, char * b, char * eb, int a)
{
If (f - & gt; _IO_buf_base & amp; & ! (f - & gt; _flags & amp; _IO_USER_BUF))
Free (f - & gt; _IO_buf_base);
F - & gt; _IO_buf_base=b;
F - & gt; _IO_buf_end=eb;
If (a)
F - & gt; _flags & amp;=~ _IO_USER_BUF;
The else
F - & gt; _flags |=_IO_USER_BUF;
}

CodePudding user response:


I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10581430.html
I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10768339.html
  • Related