Questions tagged [buffer]

A buffer is an area of memory set aside for temporary storage of data while it is being moved from one place to another. This is typically done to speed up processes with significant latency, such as writing to a disk, printer or other physical device. The output is ready to be sent to the device before the device is ready to accept it, so it is moved to the buffer so that the sending program does not have to continue waiting.

A may be used when moving data between processes within a computer. This is comparable to buffers in telecommunication. Buffers can be implemented in a fixed memory location in hardware—or by using a virtual data buffer in software, pointing at a location in the physical memory. In all cases, the data stored in a data buffer are stored on a physical storage medium. A majority of buffers are implemented in software, which typically use the faster RAM to store temporary data, due to the much faster access time compared with hard disk drives. Buffers are typically used when there is a difference between the rate at which data is received and the rate at which it can be processed, or in the case that these rates are variable, for example in a printer spooler or in online video streaming.


References

7035 questions
23
votes
5 answers

Why is buffering in C++ important?

I tried to print Hello World 200,000 times and it took me forever, so I have to stop. But right after I add a char array to act as a buffer, it took less than 10 seconds. Why? Before adding a buffer: #include using namespace std; int…
Amumu
  • 17,924
  • 31
  • 84
  • 131
23
votes
1 answer

Convert bytes into BufferedReader in python

I have a bytearray and want to convert into a buffered reader. A way of doing it is to write the bytes into a file and read them again. sample_bytes = bytes('this is a sample bytearray','utf-8') with open(path,'wb') as f: …
Uchiha Madara
  • 984
  • 5
  • 16
  • 35
23
votes
3 answers

decodeAudioData HTML5 Audio API

I want to play audio data from an ArrayBuffer... so I generate my array and fill it with microfone input. If I draw this data on a canvas it looks like --> So this works! But if i want to listen to this data with context.decodeAudioData(tmp,…
Cracker0dks
  • 2,422
  • 1
  • 24
  • 39
23
votes
1 answer

How to send larger than 4k queries from SQL buffer to sql-mysql buffer in Emacs?

I've frequently run into an annoyance in Emacs's sql-mysql mode, and I'm wondering if anyone has a solution or better workaround. Anytime I try to send a query from an sql-mode buffer to an active SQL process buffer, that query cannot be larger than…
Ryan M
  • 688
  • 6
  • 12
22
votes
3 answers

How to create a std::string directly from a char* array without copying?

Say I have an array of chars, which I have allocated on the heap, and which I want to convert into an std::string. Currently I am doing the following: char *array = new char[size]; WriteIntoArray(array, size); std::string mystring(array); delete[]…
fyhuang
  • 2,147
  • 5
  • 21
  • 24
22
votes
2 answers

How can I animate an object in WebGL (modify specific vertices NOT full transforms)

Okay, I am new to 3D graphics and I want to animate individual specific vertices in a model (NOT whole model transforms). My script is largely based off the NEHE webgl tutorial. In this tutorial all object vertices are stored in a buffer, which is…
Josh Mc
  • 9,911
  • 8
  • 53
  • 66
22
votes
3 answers

JavaScript: reading 3 bytes Buffer as an integer

Let's say I have a hex data stream, which I want to divide into 3-bytes blocks which I need to read as an integer. For example: given a hex string 01be638119704d4b9a I need to read the first three bytes 01be63 and read it as integer 114275. This is…
kmachnicki
  • 365
  • 1
  • 3
  • 9
22
votes
3 answers

Default buffer size for a file on Linux

The documentation states that the default value for buffering is: If omitted, the system default is used. I am currently on Red Hat Linux 6, but I am not able to figure out the default buffering that is set for the system. Can anyone please guide…
name_masked
  • 9,544
  • 41
  • 118
  • 172
22
votes
19 answers

Faster approach to checking for an all-zero buffer in C?

I am searching for a faster method of accomplishing this: int is_empty(char * buf, int size) { int i; for(i = 0; i < size; i++) { if(buf[i] != 0) return 0; } return 1; } I realize I'm searching for a micro optimization…
Rob
  • 5,223
  • 5
  • 41
  • 62
21
votes
6 answers

Buffer is not defined in React-vite

Buffer is not defined after migrating from CRA(create react app) "vite": "^2.7.12" I try to add plugins, add define for Buffer, but it's not work. const viteConfig = defineConfig({ /* define: { "Buffer": {} },*/ plugins:…
21
votes
1 answer

spyder Ipython console buffer

I'm using Spyder 3.5 and trying to change the number of IPython Console buffer line. The default is 500 lines. But no matter what number I change to, the limit is still 500, and I cannot scroll back beyond 500 lines. I also open a new console after…
user87313
  • 313
  • 1
  • 2
  • 6
21
votes
9 answers

How can I open a help file in Vim on a new buffer in an existing window?

I often take a look at help files in Vim, but sometimes I want to read one in full screen. Since the :help command opens it in a new window, and closing the old window, if it was the only one besides of the help file, for some reason closes Vim, the…
Martín Fixman
  • 9,055
  • 9
  • 38
  • 46
21
votes
3 answers

Specifying the maximum string length to scanf dynamically in C (like "%*s" in printf)

I can specify the maximum amount of characters for scanf to read to a buffer using this technique: char buffer[64]; /* Read one line of text to buffer. */ scanf("%63[^\n]", buffer); But what if we do not know the buffer length when we write the…
wefwefa3
  • 3,872
  • 2
  • 29
  • 51
20
votes
2 answers

Emacs switching out of terminal

When running terminal mode in Emacs using M-x term using C-x C-o I cannot switch to another buffer to continue working on things. I know that this is possible with M-x shell but with this command there are certain aspects of the shell that do not…
Jesus Ramos
  • 22,940
  • 10
  • 58
  • 88
20
votes
2 answers

What is the most efficient way to stream data between Docker containers

I have a large number of bytes per second coming from a sensor device (e.g., video) that are being read and processed by a process in a Docker container. I have a second Docker container that would like to read the processed byte stream (still a…
eraoul
  • 1,072
  • 12
  • 19