buffer

ruby equivalent of a c buffer

I am working on a small script using the USB bindings for ruby. Since this is just a wrapper around libusb, all of C++'s features are visible through the abstraction, for example when usb_bulk_read requires giving a buffer as an argument (which would just be a pointer in C). How can I create a buffer which is 64bytes long, for the foll...

WCF Named pipe message size problems

I am trying to get working a WCF named pipe communication between two processes on the same computer (on XP), but I am having trouble with "large" messages disappearing. The messages that disappear contain a largish byte array and I have narrowed the failure down to when the array is around 16k in size. Smaller than that and the messag...

Rotating an array of bits in C

I've just started learning C and I'm having some problems with some code I want to write. Basically I have this struct that is a bit array, with the number of bits in the array, and a pointer to a buffer of chars, that stores the bits. My strategy for rotating the bit array is simply taking the number of rotations (mod the length to a...

How do you clear the receive buffer in WinSock

I went searching for this and found at least one person who asked but got no answer. I think there is a need to start a send and receive segment (part of a larger process on same socket connection) and expect that there is nothing already in the receive buffer. I saw no answer but did think of this kludge before I myself realized anothe...

How this simple program works, I/O related

This is my program: #include <stdio.h> int main(int argc, char* argv[]) { char buf[1024] = {0}; setvbuf(stdout, buf, _IOFBF, 1024); printf("error\n"); printf("%s\n", buf); } And this is the output: error error Exited: ExitFailure 7 Why are both lines 3 and line 4 blank lines ? Isn't the character '\n' flushing the output b...

void* or char* for generic buffer representation ?

Hi, I'm designing a Buffer class whose purpose is to represent a chunk of memory. My underlying buffer is a char* (well, a boost::shared_array<char> actually, but it doesn't really matter). I'm stuck at deciding what prototype to choose for my constructor: Should I go with: Buffer(const void* buf, size_t buflen); Or with: Buffer(...

linux "more" like code in python for very big tuple/file/db records/numpy.darray?

Dear All, I am in looking for a buffer code for process huge records in tuple / csv file / sqlite db records / numpy.darray, the buffer may just like linux command "more". The request came from processing huge data records(100000000 rows maybe), the records may look like this: 0.12313 0.231312 0.23123 0.152432 0.22569 0.311312 0.54549...

Vim: Replace selection with default buffer without overwriting the buffer.

Here is my problem: I am in visual mode. I select text and copy it to the buffer. ((y)ank) I select another text which I want to replace and paste the buffer. ((p)aste) Now the second selection has been replaced in the buffer, however I want the first one to still sit in there. Any ideas? ...

How to log STDOUT of a background process w/o buffering on Mac?

I am running a background process on Mac and have a problem with log update. If I run someprog > mylog & then mylog is updated not immediately, but with some intervals - I guess it's due to buffering. Same thing with at now. If I kill the program before output is written to mylog, then I loose the data. There was no such problem with ...

Intentional buffer overflow exploit program

Hello all, I'm trying to figure out this problem for one of my comp sci classes, I've utilized every resource and still having issues, if someone could provide some insight, I'd greatly appreciate it. I have this "target" I need to execute a execve(“/bin/sh”) with the buffer overflow exploit. In the overflow of buf[128], when executing...

How to extract Y,U, and V components from a given yuv file using Matlab? Each component is used for further pixels level manipulation.

Hey guys. I'm currently playing with YUV file. Do you have any suggestion on how to extract y,u,v components from a yuv video? I found a piece of program which was shown below. But I don't know which part is the valid components that I want. Thanks. % function mov = loadFileYuv(fileName, width, height, idxFrame) function [mov,imgRgb] =...

I get CL_SUCCESS for all my OpenCL error codes, but all my clEnqueueReadBuffer calls crash the program

I am badly stuck on why my OpenCL program crashes after clEnqueueReadBuffer calls. Is it a okay if I post all 300 lines of boilerplate/kernel code? Otherwise any suggestions on how to debug OpenCL code besides eyeballing and error code printing would be appreciated. UPDATE Wow, so I merely messed up my paramter to host memory on my clEn...

How do I handle a stream of data internal to a C-based app?

I am pulling data from a bzip2 stream within a C application. As chunks of data come out of the decompressor, they can be written to stdout: fwrite(buffer, 1, length, stdout); This works great. I get all the data when it is sent to stdout. Instead of writing to stdout, I would like to process the output from this statement internally...

using ALSA api - sound does not start until buffer has filled

The application I'm using only plays sounds after enough sound has been generated. Say I click the mouse 10 times, with no sound, and then after those ten clicks I'll hear ten mouse click sounds (for example) The only way I've found to alleviate this problem is to set a very short buffer size, which I don't want to do. I've been trying...

How to initialize an NSData in order to store MAX_SIZE_BUFFER bytes ?

Hi, I have just realized I lost 30 minutes searching in Xcode NSData Class reference how to do this in objc (sorry I explain this in C as this in the only language which comes without thinking too much): #define MAX_SIZE_BUFFER 500 byte *ptr; ptr = malloc(MAX_SIZE_BUFFER * sizeof(byte)); memset(ptr, 0, MAX_SIZE_BUFFER); I started to ...

python: how to slice/store iter pointed data in a fixed buffer class?

All, As you know, by python iter we can use iter.next() to get the next item of data. take a list for example: l = [x for x in range(100)] itl = iter(l) itl.next() # 0 itl.next() # 1 Now I want a buffer can store *general iter pointed data * slice in fixed size, use above list iter to demo my question. class I...

What does the FillBuffer method of BinaryReader do?

According to the documentation: Fills the internal buffer with the specified number of bytes read from the stream. What does this mean (what's the internal buffer?)? ...

Convert 2D array of integers to bitmap in Java

I have a 2D array of integers in Java. I want to take this and output a bitmap image file where the red value of each pixel is the corresponding value in the array (blue and green values are 0). Does anyone know how to do this? Thanks. ...

Emacs: How to toggle Buffer-menu-files-only by default

In buff-menu+.el or (respectivly buff-menu.el) there is an function "Buffer-menu-toggle-files-only", which sets the variable "Buffer-menu-files-only" to true/false. When showing the Buffer list, I can toggle this with the key T. So i can prevent non-file-buffers from being shown in the list. I would like to have this filter (files-only...

Android Opengl 2d Intersection between two graphic objects

Hi, I'm new to opengl and android and couldn't find an answer in the forums so here I am... I need to be able to 'draw' only the intersection of two triangles. I tried to use stencil test but it doesn't work in the android emulator. Then I tried to use depth test and it works but only for a fraction of a second, then the screen goes bl...