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
2
votes
1 answer

Convert Bytes into BufferedReader object in Python?

The title of this question is the same as this one, and I have voted to reopoen the question. I want to convert a byte object into a BufferedReader one, and here is my attempts(after referring to many articles): import numpy as np from PIL import…
Lerner Zhang
  • 6,184
  • 2
  • 49
  • 66
2
votes
1 answer

C : memcpy to the "end" of a buffer

I got a giant buffer and I need to write strings and ints to it. I know you can write to it using memcpy / memmove. But in that case, I'd have to offset each variable. Example : int a = 10; char *s = "hello world"; char buf[100]; memcpy(buf, a,…
0xRyN
  • 852
  • 2
  • 13
2
votes
2 answers

How can I get d value from process.stdout.write(d)

I have that 'd' where is stored the access token, how can I get this value from him, if I'm using console.log(d) I'm getting this:
Hulubina
  • 141
  • 1
  • 11
2
votes
1 answer

WordPress: Securing/Escaping Output of file content - reading via @fread() in PHP

I am working on securing the content read from a file via the @fread() function. private function readfile_chunked($file) { $chunksize = 1024 * 1024; // Open Resume $handle = @fopen($file, 'r'); if (false === $handle) { …
2
votes
1 answer

NodeJS Crypto equivalent in PHP?

I'm looking for a way to decrypt a file since a few weeks. But it's impossible to recover the file intact in PHP, only with node. But I would like to do it without node. If someone can tell me where I could be wrong... ? I tried with…
2
votes
2 answers

How to pass multiple structures to one function (ANSI C)

I am writing an embedded application designed to run at about 3-7 MHz so speed is CRITICAL. also the device only has 32K of RAM. Dynamic memory allocation is NOT and option. That said... I am writing a buffering program which requires circular…
Jeremy
  • 103
  • 12
2
votes
3 answers

Why is this use of strcpy considered bad?

I've spotted the following piece of C code, marked as BAD (aka buffer overflow bad). The problem is I don't quite get why? The input string length is captured before the allocation etc. char *my_strdup(const char *s) { size_t len = strlen(s) +…
DegH
  • 53
  • 8
2
votes
1 answer

How would one generalise `clearerr()` under C++?…

TL;DR I am aware that if a program listens for EOF (e.g. ^D) as a sign to stop taking input, e.g. by relying on a conditional like while (std::cin) {...}, one needs to call cin.clear() before standard input can be read from again (readers who'd like…
mavenor
  • 168
  • 8
2
votes
0 answers

How to check if the buffer has filled up completely in Python?

I have a pipe between Node.JS and Python, and I'm sending responses back according to the received requests by Node.JS. But I want to check if the buffer is full or not in Python, and I could not find any documentation somewhere. I send responses…
ibrahim koz
  • 537
  • 4
  • 15
2
votes
1 answer

fread pointer in C

I declared a non pointer variable to use as a buffer for my fread function in C. fread specifies that the buffer should be a pointer, I used the & sign to point at the address of my variable buffer (if my logic is correct). I'm wondering, if it's a…
FatSumo
  • 79
  • 7
2
votes
2 answers

How to choose the best buffer size when you need read large data

Let's assume a scenario where I have a lot of log files for a given system, let's imagine that it's petabytes of data. This is my scenario. Used Technology For my purpose, I'm going to choose the C/C++ to do this. My Problem I have the need to…
Yuri Melo
  • 93
  • 1
  • 3
  • 12
2
votes
1 answer

Cannot export 'Buffer'. Only local declarations can be exported from a module

i want to change the styling of an opensource app developed with angular and when i tried to build it with ng build --watch i get the following error : Error: node_modules/@types/node/buffer.d.ts:90:14 - error TS2661: Cannot export 'Buffer'. Only…
2
votes
1 answer

Bidirectional iterator from char * buffer with size

I can't seem to be able to find an easy simple solution, how to get bidirectional iterator from char *buffer with defined bufferSize. I don't want to copy the buffer to std::string (too expensive), I just want something like…
tach
  • 663
  • 12
  • 19
2
votes
3 answers

Issue with clearing buffer in C

I'm trying to read some strings from keyboard and save them to the arrays. I specified maximum number of characters to be read and clear buffer after middle initials to discard all character and exceed limit. Everything seems fine as soons as I type…
Gipsy King
  • 186
  • 2
  • 2
  • 14
2
votes
3 answers

Trying to get numpy image from gstreamer appsink results in buffer too small error

I'm trying to get a numpy array out of an gstreamer appsink buffer. But the buffer is to small for numpy to fit it in an array. I picked up on a little bit of code from here: Receive Numpy Array Realtime from GStreamer I use videotestsource that…
user3379159
  • 111
  • 2
  • 12