FAQ Database Discussion Community


BufferOverFlowException at first .put()

java,opengl,buffer,lwjgl
I was having a problem due to not flipping the buffer previously, but now I can't get the buffer to add anything with the .put() or .putInt() it constantly throws the BufferOverflowException at the first attempt of: buffer.put((byte) c.getRed()); The relevant code below: BufferedImage image = loadImage(".\\res\\" + fileName); int[]...

How to detect buffer overflow in C for this particular case,

c,buffer,buffer-overflow
I think this code should produce a buffer overflow error but apparently, this prints fine.. is there anyway to detect it has overflown? Valgrind didn't picked it up either... static void e(void) { char buffer[5]; char data1[] = "abc"; char data2[] = "de"; memcpy(buffer, data1, sizeof(data1)); // strcat appends data2...

stop printf printing twice running check framework in C?

c,printf,buffer,check-framework
Probably a deep explanation of how printing in general in c and c threads happen would solve the issue There aren't loops and scanf used at any point Because my code uses check framework I would assume there is some forking going on. Most likely it is something to...

Overlapping and too long integer values in dynamic c structs

c,printf,buffer
I have the following problem. I need to create a list of savestates with dynamical length. That's why I decided to create a list by defining some structs and connecting dynamically created structs together to build a list of structs which can dynamically be extended and so on. However, some...

excel vba sort error 1004

excel,vba,sorting,buffer
i'm using this code for sorting (checked for Excel 2010/2013): Worksheets("Tabelle4(1)").Activate ActiveSheet.Sort.SortFields.Add Key:=Range( _ "W2:W51"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:= _ xlSortNormal I loop over a sheet 70 times with different values and sort and export them as a pdf. Everything works fine, but after approximately 30 times I get an error...

Google Protobufs in Java: How do you get a Message.Builder from a FieldDescriptor?

java,buffer,protocols,protocol-buffers
I have a FieldDescriptor for a message field defined in my protocol buffer. I want to start constructing a value for that field, but I'm stuck trying to get a Message.Builder for that FieldDescriptor. The code I'm writing is extremely generic - It's designed to serialize between MongoDB and Protocol...

Forcing a program to call a function in C with an input string

c,gdb,buffer,machine-code
So I'm doing an exercise where I want to call the function void not_called() just by inputting a buffer. Basically what I want to do is use a buffer overflow to call not_called(). I'm approaching this by using a binary exploit string then using a program hex2raw (takes hex format...

Python buffer decode

python,buffer,decode,encode
I have a UDP package that is sent from a C++ program and I have to read it in Python. I managed to receive the UDP package but unfortunately it is encoded. The C++ data has the form struct packet{ double arg1 double arg2 double arg3 double arg4 int16_t arg5...

Does [NSData getBytes: length:] change position in buffer?

objective-c,buffer,nsdata
I have some NSData instance with 2 bytes of different value. Will calling getBytes: of any kind (length, range...) also advance the current position in the buffer? Example: NSData *data = ...; // 2 bytes data [data getBytes:&whatever1 length:1]; // reading first byte [data getBytes:&whatever2 length:1]; // reading first OR...

Setting Socket Receive Buffer Size, gets truncated to 244KB

linux,sockets,buffer
I'm trying to increase the size of my socket receive buffer size using setsockopt() on linux. I can set it successfully to any value below 244KB. Any value above 244KB gets truncated to 244KB. There appears to be some sort of system limit in place, but I can't figure where...

Screen flickers when setting background

java,swing,double,buffer,flicker
I'm trying to make a simple GUI program without using JComponents. Currently, I have a BufferedImage that I draw to off screen so that it doesn't flicker (or so I thought). I made a new program here to replicate the issue: package Main; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import...

C Buffer overflow test - Seg fault on 64 bit when it shouldn't?

c,gcc,buffer
I have the following code that I'm using to test buffer overflow: #include <stdio.h> #include <string.h> int PasswordOkay() { char GoodPassword = 'F'; printf("The memory address of GoodPassword is: %p\n", (void*) &GoodPassword); char Password[8]; printf("The memory address of password is: %p\n", (void*) &Password); gets(Password); if(!strcmp(Password, "SPOCKSUX")) GoodPassword = 'T'; return...

Retrieving File Data Stored in Buffer

c++,performance,buffer,ifstream,large-files
I'm new to the forum, but not to this website. I've been searching for weeks on how to process a large data file quickly using C++ 11. I'm trying to have a function with a member that will capture the trace file name, open and process the data. The trace...

how to write buffer for compiler?

c#,compiler-construction,buffer
I want to write compiler with C# for the first time and I somehow lost what to do about its buffering!my reference is compilers principles,techniques and tools and it is said that : Because of the amount of time taken to process characters and the large number of characters that...

c#: strange shift in data buffer during communication with device

c#,serial-port,buffer
In my app I have to receive and process some data from device, connected through COM port. I do it partially. In that particular device first two bytes are the length of the packet (minus 2 since it doesn't take into account these very two bytes; so it is length...

iOS Streaming MP3 File

ios,audio,streaming,buffer,mp3
I am a relatively new developer to iOS and I am writing an application that deals with streaming audio from an mp3 file on a website. I want to play the audio as I stream it and I want the user to be able to scrub through the audio. I...

How to convert a hex address from a char buffer to be written to memory

c,string,assembly,hex,buffer
So i got this function here, which is called from the main function: void overflow(char *arg) { char buf[1369]; strcpy (buf, arg); printf ("Thank you for contacting customer service. You are so important to us that we wrote a program to serve you.\n"); printf ("Please hold for %u minutes while...

Performance Loss when Writing to Memory Buffer (C++)

c++,memory,memory-management,buffer
I am writing a small renderer (based on the rasterisation algorithm). It's a personal project I am doing to test different techniques. I was measuring the time it took to render a bunch of triangles, and while doing this I noticed something strange. What the program does is write to...

how to convert getUsermedia audio stream into a blob or buffer?

javascript,buffer,blob,webrtc,audio-streaming
I am getting audio stream from getUserMeda and then convert it into a blob or buffer and send it to server as audio is comming I am using socket.io to emit it to server how can i convert audio mediastream into buffer? Following is the code that i have written...

Dynamic Constantbuffer or Dynamic Vertex Buffer in c++ and DX11

c++,dynamic,buffer,directx-11,vertex-buffer
I have a question realted to meemory usage by using Dynamic ConstantBuffer vs Constant Buffer updated frequentlky(Using Defualt usagetype) vs Dynamic Vertex Buffer I always Defined Constnat buffer usage as defualt and updated the changes in realtime like so Eg 1 D3D11_BUFFER_DESC desc; desc.Usage = D3D11_USAGE_DEFAULT; // irrelevant code omitted...

In Bash, what happens when you pipe several asynchronous commands to one consumer?

bash,asynchronous,parallel-processing,pipe,buffer
Consider this Bash code: (cmd1 & cmd2) | consumer What possible things might consumer see on its standard input? output from cmd1, then output from cmd2? lines from cmd1 interspersed arbitrarily with lines from cmd2? bytes from cmd1 interspersed arbitrarily with bytes from cmd2? something else? ...

Why does inputting an unexpected value type via scanf() cause this program to enter an infinite loop

c,types,buffer,scanf
Consider the following code snippet: int n; int a[100]; int main() { printf("\nThis program will sort a given list of between 1 and 100 integers.\n\n"); int ready = 0; while(!ready) { printf("How many integers are in your list? "); scanf("%d",&n); if(n>100) { printf("\n\nError:\tToo many integers.\n\tThis program can only handle up...

OpenGL 4.5 Buffer Texture : extensions support

opengl,cuda,textures,buffer,opengl-4
I use OpenGL Version 4.5.0, but somehow I can not make texture_buffer_object extensions work for me ("GL_EXT_texture_buffer_object" or "GL_ARB_texture_buffer_object"). I am quite new with OpenGL, but if I understand right, these extensions are quite old and even already included in the core functionality... I looked for the extensions with "OpenGL...

How to get rid of the space/ enter of the input buffer in vim?

c,buffer
#include <stdio.h> #include <string.h> #include <stdlib.h> struct st{ char n[100]; //Name char d[100]; //lastname } arr[4]; void add(int *c, struct st l[]) { int i =*c; int arrSize =sizeof(arr) / sizeof(arr[0]); if((*c)<arrSize) { printf("Enter a name :\n"); fgets(l[i].n, 100,stdin); printf("Enter lastname :\n"); fgets(l[i].d,100,stdin); printf(" SUCCESS. Person was added\n"); }...

Char pointer equal to buffer plus buffer size?

c++,c,pointers,buffer
Can someone explain this code to me? Or confirm my view on it? char *buffer is allocated to point to "Hello World\0" And the buffer_size is the 12. So: char *var = buffer + buffer_size - 1; Now *var points to the 'd' in "Hello World", correct?...

Buffer.Copy RangeError

node.js,buffer
This piece of code produces the following sample output: buf = new Buffer( end - start ); console.log(buf.length); console.log(data.length); console.log(start); console.log(end); data.copy( buf, 0, start, end ); Fist call: 3732395 // buf.len 3732395 // data.len 0 // start 3732395 // end Second call: 29611 // buf.len 3732395 // data.len 3702784...

Managing Emacs *Man* buffer location?

emacs,buffer,man
Emacs behaviour which recently[*] started to irritate me: I edit the file, and need some help M-x man something emacs politely splits frame into two windows and opens manpage there, I see both source and man, great while reading man I find that I need to followup further, so I...

Winsock asynchronous multiple WSASend with one single buffer

asynchronous,buffer,winsock,send,iocp
MSDN states "For a Winsock application, once the WSASend function is called, the system owns these buffers and the application may not access them." In a server application, does that mean that if I want to broadcast a message to multiple clients I cannot use a single buffer that holds...

Does WSASend() hide batching of large buffers?

tcp,buffer,winsock
I'm testing large buffers right now and I am setting it in WSABUF and calling WSASend() next. Thing though, is that WSARecv() just handed it back that large buffer in one go. Does that make sense? Where is the limit of WSASend() and WSARecv() with with respect to large buffers?...

An implementation of integer buffer that creates deadlock

multithreading,graph,buffer,deadlock,producer-consumer
Let’s consider the following pseudocode: class OneBuf{ Mutex m; CondVar cv; int buffer; bool full; void put(int data){ m.lock(); while(full){ cv.wait(m); } buffer = data; full = true; cv.signal(); m.unlock(); } int get(){ int data; m.lock(); while(!full){ cv.wait(m); } full = false; data = buffer; cv.signal(); m.unlock(); return data; }...

Java: FloatBuffer to OpenGL - wrap() vs. allocate() vs. BufferUtils.createBuffer()

java,opengl,buffer
Datasource: float[] v = { ... }; Working example: FloatBuffer buf = BufferUtils.createFloatBuffer(v.length); buf.put(v); buf.flip(); // or buf.rewind() The buffer can now be uploaded to opengl and works fine: ... glBufferData(..., buf, ...); ... Why do the following examples of the buffer creation not also work? Not working 1: FloatBuffer...

Buffer overflow in C with gets

c,buffer,buffer-overflow
I am very new to C and as a class assignment my instructor wanted us to play with buffer overflows. I found the following online as an example and I can't figure out how to use it! #include <stdio.h> char temp[32]; unsigned int setThis=1; printf("Enter your temp: \n"); fgets(temp, 34,...

Flushing Twisted's write buffer

python,tcp,buffer,twisted
Twisted's Connection class inherits the write method from the abstract class FileDescriptor. As you can see here, the class has a buffer which is not flushed until the total number of buffered bytes is greater than bufferSize (attribute in class FileDescriptor). For my specific needs, I'd like to write data...

Disable “buffered view” when display 'git' commands results

linux,git,shell,buffer
I just switched to a new (already configured) development box. Now git behaves differently, with some commands. Let me try to explain it: before (on the other machine) when typing git log I was getting the list of commits in my terminal. So I could just scroll up and copy/past...

Need to avoid buffer overflow upon user entry over 8 chars above

c,if-statement,buffer,overflow
I am trying to restrict the amount of entered chars to 8, if more is entered then the program should stop or display a msg and stop. #include <stdio.h> #include <string.h> int main(int argc, char *argv[]) { int value = 5 char buffer_one[8], buffer_two[8]; strcpy(buffer_one, "one"); /* put "one" into...

Execute external Javascript NodeJS

javascript,node.js,buffer,eval,external
I would like to execute an JS file passed in argument in my NodeJS app (without require each others) Example : $ node myapp test.js test.js console.log("Do some work") test(); myapp.js var test = function(){ console.log("Test working"); here_execute_js_in_process.argv[2](); I tried the simplest option, read file thanks to fs.readFile and eval...

Unbinding a WebGL buffer, worth it?

performance,buffer,webgl
In various sources I've seen recommendations for 'unbinding' buffers after use, i.e. setting it to null. I'm curious if there is really a need for this. e.g. var buffer = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, buffer); // ... buffer related operations ... gl.bindBuffer(gl.ARRAY_BUFFER, null); // unbinding One the one hand, it's likely better...

Unable to set the offset for buffer in the datagramPacket object

java,sockets,buffer
In the java library, http://download.java.net/jdk7/archive/b123/docs/api/java/net/DatagramPacket.html I want to construct my datagram packet object using this constructor; DatagramPacket(byte[] buf, int offset, int length, InetAddress address, int port) Here is my code: ByteArrayOutputStream outputStream = new ByteArrayOutputStream( ); outputStream.write( by); // by is a buffer that contains filename outputStream.write(buffer); // buffer contains...

Copying bytes in Python from Numpy array into string or bytearray

python,arrays,numpy,buffer
I am reading data from an UDP socket in a while loop. I need the most efficient way to 1) Read the data (*) (that's kind of solved, but comments are appreciated) 2) Dump the (manipulated) data periodically in a file (**) (The Question) I am anticipating a bottleneck in...

About choose buffer size in HttpWebRequest GetResponseStream

c#,httpwebrequest,size,buffer
var h = (HttpWebRequest)WebRequest.Create(url); using (var hr = (HttpWebResponse)(await h.GetResponseAsync())) { using (var s = hr.GetResponseStream()) { using (var f = new FileStream(saveTo, FileMode.Create, FileAccess.Write, FileShare.None)) { int bytesCount = 0; byte[] buf = new byte[2048]; //<------------------------------ while ((bytesCount = await s.ReadAsync(buf, 0, buf.Length)) > 0) { await f.WriteAsync(buf, 0,...

error due to the configuration of the solver “fixed-step”

matlab,buffer,simulink
I tried my whole Simulink model with the configuration which are mentioned in the answer of my previous question by am304.But, an error concerning the fixed step size appears to me. Unfortunately, I couldn’t understand what it means: The computed fixed step size (2.195764022074938e-011) is 1000000 times smaller than all...

python buffer size when querying Vertica using Pyodbc

python,buffer,pyodbc,vertica
i am using pyodbc to connect to Vertica DB and then i am using cursor to execute a query but the results of the query include a text field that is huge, the execute runs but it never returns anything, not even an exception. I can see this when i...

Count number of buffers that touch a (polygon) feature

buffer,polygon,geospatial,spatial,arcgis
I'm facing the following task in ArcGIS - I'm using ArcMap 10.2 I have a polygon shapefile with counties of (say) a state in US. From this shapefile, I create a layer which marks all counties in which there is at least 1 city of more than 50000 inhabitants (I...

Confusion regarding frequent updates of instanced array using glBufferSubData

c++,opengl,buffer,gpu
I'm rendering large patches of grass using instanced rendering and for that I use an instanced array consisting of a large number of 4x4 transformation matrices. I use a LOD algorithm on the grass leaves to determine which leaves to render based on their distance to the camera. For this...

Want to know the length of a buffer C++

c++,qt,file,buffer,variable-length
I am new to C++ and programming and I would like to know if there is a way to get the length of a pointer. Let's say Myheader is a struct with different types of data inside. My code goes like this: char *pStartBuffer; memcpy(pStartBuffer, &MyHeader, MyHeader.u32Size); So I want...

How to fix One Function has been called 2 times have 2 value?

java,function,buffer,value
I've an array including four digits. A function calculates them and returns the value by one var Total. Then, I call another function which deletes one digit from the array and calls the calculate function afterwards. The final value I got was Total + Total (After it deletes one digit)....

opengl - use large (100k) uniform array in shader

c++,opengl,glsl,buffer
In my program I am doing a single render of one model. I have a generated array of unsigned chars where all bits in each byte can be used. There is an element in the array for each triangle in the model. To get the color for the triangle I...

Python 3 : TypeError: Type str doesn't support the buffer API

python,python-3.x,buffer
I'm getting the error : TypeError: Type str doesn't support the buffer API when trying to run the following code : import random import string WORDLIST_FILENAME = "words.txt" def loadWords(): """ Returns a list of valid words. Words are strings of lowercase letters. Depending on the size of the word...

Does RandomAccessFile.read() from local file guarantee that exact number of bytes will be read?

java,buffer,randomaccessfile
Currently my code works fine but should I replace raf.read() to raf.readFully() in order to ensure that all bytes will be read? raf = new RandomAccessFile(doc.getFilePath()+"/"+doc.getName(),"r"); raf.seek((partNumber-1)*partitionSize); byte[] buf = new byte[partitionSize]; int bytesRead = raf.read(buf); //ensure myself by readFully or not? System.out.println("expected="+partitionSize+" readed="+bytesRead); My suggestion is the following -...

Audio Queue Buffer Empty Error

ios,objective-c,buffer,memcpy,audioqueue
I allocate buffers and start audio queue like // allocate the buffers and prime the queue with some data before starting AudioQueueBufferRef buffers[kNumberPlaybackBuffers]; isDone = false; packetPosition = 0; int i; for (i = 0; i < kNumberPlaybackBuffers; ++i) { CheckError(AudioQueueAllocateBuffer(queue, packetBufferSize, &buffers[i]), "AudioQueueAllocateBuffer failed"); // manually invoke callback to...

import a continuous bitsream from workspace into simulink using “In” block and then buffer it using “buffer” block

matlab,import,buffer,simulink
how to import a bitsream form binary vector from workspace into simulink.Actually I have found that I can use simin block or In block but my binary vector is independant of time. I tried to use Const block and it works but afer that when I wanted to put my...

what will be done if the buffer socket full

networking,udp,buffer,protocol-buffers
what will be done if the buffer socket full in an UDP protocol? does it replace the old data with the new one? ot it just drop the new data? In case that it's not related with UDP protocols, and it's specified in the code, how to do this in...

Extract xy coordinates from raster using buffer function

r,buffer,extract,spatial,raster
I have some xy coordinates as a SpatialPoints (points) object and have used them to extract temperature values at these locations from a RasterLayer (raster): extract = extract(raster, points) However several of the points are falling outside of the raster layer (i.e. not plotting on land) and I want to...

Potential issues with p* in structs?

c,pointers,struct,buffer
I have been churning through C for the last several months. In an effort to learn the language, the project is an arithmetic parser - formulas, variables, etc. I recently decided to go ahead and work out garbage collection because I have a lot of calls to this method: char*...

Specified argument was out of the range of valid value to get data from network in c#

c#,sockets,buffer,streamwriter
I am trying to send a command to a sensor and get the data from it using this code : const int PORT_NO = 3000; const string SERVER_IP = "192.168.2.44"; //---listen at the specified IP and port no.--- IPAddress localAdd = IPAddress.Any; TcpListener listener = new TcpListener(localAdd, PORT_NO); Console.WriteLine("Listening..."); listener.Start();...

How to build WriteBuf from array

buffer,rust,traits
I am serializing two values in to an array and I am trying to go through a WriteBuf but I am getting the error that error: the trait `std::io::Write` is not implemented for the type `[_; 12]` error: type `std::io::buffered::BufWriter<&mut [_; 12]>` does not implement any method in scope named...

C programming - globally seen instance

c,buffer
I want to declare an instance of a structure which will be accessible in all source files. To be more precise, I have a structure which represents a ring buffer. Two parts of my program can write to the buffer, so I need somehow to share the same instance of...

C++ Using function with sprintf_s inside sprintf_s

c++,char,buffer
I want to write data into a char buffer. Therefore I have a function to format my data. As an example, I just pass an int value to the function like this: using namespace std; #include <iostream> char* writeData(int iData, char* sBufferData){ sprintf_s(sBufferData, 2048, "val:%i", iData); return sBufferData; } int...

Very random behaviour in Node with gm, buffers and promises

node.js,buffer,q,graphicsmagick
I recently switched my image saving module over to gm (grahicsmagick) and began using buffers instead of saving to disk. The output I expect is an array with an md5 hash, then the paths to the original image and the thumbnail. I use promises, like this. saveOrig( imageUrl ) .then(...

Scala trait, superclass and early definition syntax

scala,inheritance,buffer,inputstream,trait
I'm learning Scala by working the exercises from the book "Scala for the Impatient". One exercise asks that: In the java.io library, you add buffering to an input stream with a BufferedInputStream decorator. Reimplement buffering as a trait. For simplicity, override the read method. Even though it isn't clear (to...

Python Overwrite Dictionary to Text File doesn't work… why?

python,dictionary,interface,buffer,python-idle
I've been previously writing code for a quiz program with a text file that stores all of the participants' results. The code that converts the text file to a dictionary and the text file itself are shown below: Code: import collections from collections import defaultdict scores_guessed = collections.defaultdict(lambda: collections.deque(maxlen=4))...

String Comparison from text file does not return anything

string,comparison,buffer
i am a beginner in Java, i was trying to read a text from a text file and compare it to Strings i created within my class, for some reason it does not output anything on the console and i can't help but wonder why. Here's my simple code package...

OpenGL Index Buffering To Make A Square

c++,opengl,indexing,buffer
I'm new to OpenGL and have been following the YouTube tutorial by Jeffrey Chastine. As a personal exercise, I wanted to make a simple square using index buffers. Sadly with my attempt, I only see one triangle drawn (when I expect two). I'm not sure what I'm missing. Here is...

c++ derive struct to manage different version

c++,buffer
I need to read some data from a binary file, this file contains some data frames with a different size, depending on the version. For example: version 1 has a frame of 32 floats, version 2 has a frame of 48, etc... I store in the header the file version,...

How can I convert a string or multiple strings into different ranges within a byte array in Java?

java,string,char,buffer,bytearray
I have a set of strings for fields like name, userID, email, etc. which need to go into a byte[] array of a certain size (1024 bytes). I would love to find a method/function that would allow me to simply use my index variable bufferPosition like the following: byteArray[bufferPosition] +=...

Writing buffer response from resemble.js to file

node.js,buffer,resemblejs
I'm using node-resemble-js to compare two PNG images. The comparison happens without issue and I get a successful/relevant response however I'm having trouble outputting the image diff. var express = require('express'); var fs = require('fs'); var resemble = require('node-resemble-js'); var router = express.Router(); router.get('/compare', function(req, res, next) { compareImages(res); });...

Convert byte array to generic value type?

c#,generics,types,stream,buffer
I have a Stream where I'd like to read data from (as value type segments) and move the position according to the size of the given type (declared as generics). My current approach: public byte ReadUInt8(Stream stream) { return (byte)stream.ReadByte(); } public ushort ReadUInt16(Stream stream) { return (ushort)((ReadUInt8() << 8)...

Audio Queue is playing too fast when the buffer size is small

ios,objective-c,buffer,audioqueue,audioqueueservices
I am able to stream and play m4a files using Audio File Services + Audio Queue Services. Bitrate information of the file is not available to the Audio Queue because of file type. After downloading the all of the audio packets I feed them to the player. When I choose...

Real-time monitoring of intermittent binary data

linux,terminal,binary,buffer,monitoring
Context: monitor a low-volume, intermittent stream from a program When debugging some program, one sometimes have to monitor some output. When output is ascii, no problem, just run in terminal (the program itself, or nc if it uses a TCP or UDP interface, or cat /dev/somedevice, or socat ..., whatever)....

Why is buffered I/O faster than unbuffered I/O

c,file,io,buffer
While reading this, I found a reasonable answer, which says: Case 1: Directly Writing to File On Disk 100 times x 1 ms = 100 ms I understood that. Next, Case 3: Buffering in Memory before Writing to File on Disk (100 times x 0.5 ms) + 1 ms =...

Replacing Strings Java

java,string,replace,buffer,lowercase
I have this function to check if some words appear in a specific line, and then surround them with a given char. The code above works like a charm, however since the words in the string array "words" are always low case, the words will be lower case as well....

Byte buffer in Java?

java,buffer
Since I found out that it's impossible to have unsigned bytes in java, and that essentially they take up the same memory as an int, is there really any difference when you send them over a packet? If I send a Java byte via tcp or udp via(Games.RealTimeMultiplayer.sendReliableMessage) would that...

Adding custom text to UITextField buffer

ios,objective-c,text,buffer,homekit
Background: I have got a custom alert part of the HomeKit API. I'd like to allow the user to paste the code requested rather than inputting it manually. Whenever there is text in the buffer it is possible to paste it by tapping on the textfield. How can I add...

Why does the console cout some wrong letters after memcpy of a char*

c++,buffer,memcpy
I copy a char* to a char* and get it back and coutit. char buffer[100] = { 0 }; char* name = "foo"; int bar = 12345; memcpy(buffer, &(bar), 4); memcpy(buffer + 4, name, 3); int result = 0; memcpy(&result, buffer, 4); char backname[3]; memcpy(backname, buffer + 4, 3); std::cout...

JavaScript: reading 3 bytes Buffer as an integer

javascript,node.js,buffer
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 what I...

InputStreamReader buffering

java,character-encoding,buffer,inputstream
In the InputStreamReader class documentation it is declared that: To enable the efficient conversion of bytes to characters, more bytes may be read ahead from the underlying stream than are necessary to satisfy the current read operation. what does this statement mean ? Does the implementation buffer some input data...

socket buffer size: pros and cons of bigger vs smaller

c#,sockets,c#-4.0,tcp,buffer
I've never really worked with COM sockets before, and now have some code that is listening to a rather steady stream of data (500Kb/s - 2000Kb/s). I've experimented with different sizes, but am not really sure what I'm conceptually doing. byte[] m_SocketBuffer = new byte[4048]; //vs byte[] m_SocketBuffer = new...

Unable to transmit the audio bytes from Mic over network

java,udp,byte,buffer,audio-streaming
I tried recording data from the mic as bytes ans sending to the java UDP server. But the server only plays white noise. I think I have no issue with Server. I have difficult in transmitting the recorded bytes to the server. Here is my code public class Mic {...

Guarantee disk cache was flushed with fsync

buffer,flush,hard-drive
I understand that fsync system call moves dirty data from kernel buffer cache (page cache) to HDD. Does it guarantee that hard disk moved said data from its internal cache to platter?

MongoDB insert UUID only using middleware?

node.js,mongodb,buffer,uuid
i dont know how to insert UUID into MongoDB properly. For example: db.users.insert({ uuid: UUID(buffer) }) Buffer must be 32 hex string and MongoDB natively dont create UUID, only stores this? I'm right? But where i create the random UUID, e.g through Node.js middleware i have a random UUID 11986aba-7c5a-4626-b354-80be23c25516,...

Specifing the maximum string length to scanf dynamically in C (like “%*s” in printf)

c,io,size,buffer,scanf
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 code? What if it is...

Communication Android with Arduino Buffer incomplete

java,android,arduino,buffer
i'm trying to send some data from Arduino to Android device, i saw some examples but the communication is from Android to Arduino but i want to receive some data example: Serial.write("holamundo"); via OTG, the connection is sucessful but i have some problem with this code. @Override public void run()...

How to break a string, that was read using fgets(), using scanf(“%s”,..)

c,buffer,scanf,fgets
I am working on a program that takes a mathematical expression, transforms it to posfix notation and then solves it. First I am checking the expression to see if it is well formed ( Open brackets and parenthesis matches the closing ones ). To do the part of checking I...

php output system() in real time

php,firefox,buffer
I'm trying to make a system call and have each line sent to the browser in real time echo('<pre>'); system('ping -c 10 www.google.com'); echo('</pre>); This works when I call it from the command line (each line of the ping is output one at a time). However it does not work...

fread weird behavior in c

c,buffer
I wrote a code just to understand how fread works and I don't understand how this is possible. Here my code : #include <stdio.h> #include <stdlib.h> void main(){ char spool[5] = "hello"; fread(spool, sizeof(char), 6, stdin); //stdin == "bonjour" printf("\n%s\n", spool); } So first, I thought spool's value would be...

Comparing Strings using a buffer

java,string,compare,buffer
I have a problem when comparing Strings. Let's say for example I have a buffer for a string that holds 1024 bits. If I fill that buffer up with the String "Hello", then the buffer would contain "Hello" + the remaining amount of bytes. If I create another String assigned...

С++ Embedded Python and create_string_buffer

python,c++,arrays,buffer
I'm a newbie in Python and embedding it too. And I have one problem: There is function in my python module that recieves buffer created with ctypes.create_string_buffer(size) and fills it by content from some memory address: def get_mem(self, address, size, data): self.mem.read_ram_block(address, size, data) How should I call this method...

OpenGL in Windows Forms (c++) - Buffer overflows?

winforms,opengl,memory,buffer,overflow
I wrote a program in c++ using Windows forms. I use two Forms. The first form only contains a button. When it is pressed, a second form opens. This form contains a panel where a simple OpenGL simulation is played (rotated with the help of a timer provided by windows...

c++ compress with libzpaq to char* buffer

c++,vector,compression,buffer
I have a std::vector<short> and would like to compress (and later decompress) with the libzpaq from https://github.com/zpaq/zpaq/ to something like char* buffer. However I don't get the concept of this Reader and Writer class mentioned in the header file. How do I put my std::vector in to get a compressed...

checking cin input, clearing input buffer

c++,buffer,cin,typechecking
New to c++ - trying to check for format of input. Have tried everything, at wit's end. Any help would be appreciated. I've broken down my problem to this basic case: while(1) { cin >> x; cout << "asked!" << endl; cin.ignore(1000, 'n'); } will result in infinite loop of...