1
голосов
2ответов
5366 просмотров

Создание доступа к общей памяти в C

Итак, у меня возникла проблема, и я не знаю, как ее решить.Я надеялся, что вы дадите мне знать, как с этим бороться. Мне нужно выделить N буферов в общей памяти.Каждый буфер должен быть инициализирован нулем. Затем я должен выполнить форк N / 2 дочерних процессов. Затем каждый дочерний элем...

0
голосов
4ответов
7559 просмотров

Массив буферов в программировании на C?

Я пытаюсь создать массив буферов.Мне нужно сохранить целое число в каждом буфере.Я не совсем понимаю, как это делать. int BUFFER_LENGTH = 50; //the size of each buffer int numberOfBuffers = 10; //number of buffers int *pBuffers; //array of buffers pBuffers = (int *) calloc (num...

1
голосов
1ответов
66 просмотров

Практично ли включать в библиотеку адаптивную или оптимизирующую стратегию памяти?

У меня есть библиотека, которая выполняет ввод-вывод. Есть пара внешних регуляторов для настройки размеров буферов памяти, используемых внутри. Проведя несколько тестов, я обнаружил, что размеры буферов могут значительно повлиять на производительность. Но оптимальный размер, похоже, зависит о...

0
голосов
2ответов
181 просмотров

Разделительный код, который необходимо организовать

Я создаю приложение с застежкой-молнией, но в нем есть объявление, что я хочу разделить его в другом файле (compress-file.m), но только когда я разделяю файлы, у меня возникает ошибка при компиляции с переменной, посмотреть: [[email protected]:~/Desktop] make This is gnustep-make 2.0.2. Type 'make...

12
голосов
3ответов
16925 просмотров

Как воспроизвести звук MP3 из буфера (ByteArray / Stream) в ActionScript 3?

Итак ... У меня есть буфер с данными MP3 (если бы я сохранил этот буфер и назвал его buffer.mp3, он бы воспроизводился, но в этой ситуации мне не следует сохранять его в файловой системе). Я должен играть, но не могу, что мне делать? Я попробовал следующий код для воспроизведения этого б...

3
голосов
6ответов
3541 просмотров

How to design an efficient image buffer in C++?

I am trying to create a data buffer, more specifically, an image buffer, which will be shared among multiple modules. Those modules only reads from the buffer and don't communicate with each other at all. My difficulty is: 1.Large data size: larger than 10M per image, that means copying those da...

2
голосов
2ответов
4183 просмотров

Uploading file with WCF streaming, tiny reads from stream

I've implemented file uploading using WCF's streaming. Everything works as expected, however i faced one issue: i'm allocating 4kb buffer to read from incoming stream, but WCF reads only 255 bytes. Here is my upload function: public UploadResponse UploadFile(FileDto fileDto) { ...

2
голосов
6ответов
2377 просмотров

Call assembly in buffer in C

Is this possible? I want to place intel assembly code into a char buffer, and then execute that code from within a C program If I placed the assembly code into a buffer, could I cast it into a function pointer and call that? I am using GCC and linux

4
голосов
1ответов
2108 просмотров

Python: Extracting data from buffer with ctypes

I am able to successfully call a function with ctypes in Python. I now have a buffer that is filled with Structures of data I want to extract. What is the best strategy for this? Anything else I should post? Function: class list(): def __init__(self): #[...] def getdirentrie...

1
голосов
3ответов
528 просмотров

Java: Generalization possible between: streams, readers, char buffers, stringbuilder, ...?

Background story: There are these Source and Result interfaces for XML. These are adapters between different XML technologies in Java. Instances of these classes represent DOM, SAX, JAXB, XML streams, XML events (and even more?). The question: So, is there something comparable for plain old st...

6
голосов
1ответов
2110 просмотров

memorystream - stringstream, string, others?

i am reading in a binary file via the usual c++/STL/iostream syntax. i am copying the whole content into an dynamically allocated char array and this works fine so far. but since i want to serve parts of the content as lines to another part of the program, i think it would be better/easier to st...

-1
голосов
1ответов
1576 просмотров

How to insert repeated message in google protocol buffer _pb2.py file

How to insert repeated message in google protocol buffer _pb2.py file

6
голосов
4ответов
4296 просмотров

how can I write an ANSI C console screen buffer?

I'm working on making an ASCII based game, and everywhere I look people are saying to use Console.Write() from MSDN, which is dandy and all if you're using Windows, but I'm not. And thus, I'm trying to write a function, or group of functions in C that can alternate between two screen buffers, an...

1
голосов
4ответов
275 просмотров

Help! I get OutofMemory while Retrieving web pages

I am retrieving the HTML from the web. I get "java.lang.OutOfMemoryError: Java heap space (repl-1:3)" ;; fetch: URL -> String ;; fetch returns the string of the HTML url (defn fetch [url] (with-open [stream (. url openStream)] (let [buffer (BufferedReader. (InputStreamReader. stream)...

17
голосов
20ответов
15950 просмотров

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 unnecessary except in extreme cases, but I know...

0
голосов
4ответов
722 просмотров

C++ cin Question

Okay, I was writing a simple C++ function to combine cin'd strings. I'm working on Linux at the moment, so I don't have the luxury of a simple "getline(cin, input)" command. Here's the code so far: string getLine() { string dummy; string retvalue; do ...

2
голосов
2ответов
5159 просмотров

How to read and write bits to a byte array

I have a unsigned char buffer, and I'm wondering how I would write and read signed and unsigned bits to this byte buffer. In the Source Engine there is a class named bf_write, which two main methods (used by WriteString, WriteChar, WriteLong, etc.) use two functions named WriteUBitLong and Write...

12
голосов
2ответов
9671 просмотров

Bypassing buffering of subprocess output with popen in C or Python

I have a general question about popen (and all related functions), applicable to all operating systems, when I write a python script or some c code and run the resulting executable from the console (win or linux), i can immediately see the output from the process. However, if I run the same execu...

1
голосов
2ответов
2401 просмотров

Suggestions for a thread safe non-blocking buffer manager

I've created a simple buffer manager class to be used with asyncroneous sockets. This will protect against memory fragmentation and improve performance. Any suggestions for further improvements or other approaches? public class BufferManager { private int[] free; private byte[] buffer; ...

13
голосов
3ответов
2477 просмотров

Too many split screens opening in Emacs!

Ever since I installed emacs on a new machine I have seen an ugly behaviour. Unfortunately, my old .emacs files are rather fragmented and I can't determine whether I used to have elisp that took care of this. The problem is this: it used to be that when I performed a command that would open a ne...

1
голосов
3ответов
685 просмотров

Buffering filtering pipe on Linux

I commonly build up long, multi-command pipes on Linux/Unix to process large text files (sed | grep | sort | less , etc.). I would like to be able to use a pipeline element that would buffer everything received via stdin until a key phrase/string is detected (e.g. "SUCCESS"), at which point it r...

1
голосов
6ответов
9832 просмотров

Vim copy-paste to system buffer not behaving as expected

I'm having a headache trying to figure out why vim isn't copying to a system buffer. Here's my workflow: vim asd y1y :q vim qwe p On computerA and computerB, this works as I want it to: the line yanked from the file asd is put into the file qwe. On computerC, this doesn't work. All systems...

1
голосов
4ответов
742 просмотров

writing image to directory fail

Some overflow runtime error happens when my C++ program is trying to write some .png images into a directory. The directory where the images are written into is given as a command line argument. The program is compiled with gcc -ggdb3 -O3. It is strange that the error disappears if I change th...

16
голосов
2ответов
11863 просмотров

python file-like buffer object

I've written a buffer class that provides a File-like interface with read, write, seek, tell, flush methods to a simple string in memory. Of course it is incomplete (e.g. I didn't write readline). It's purpose is to be filled by a background thread from some external data source, but let a user t...

7
голосов
3ответов
403 просмотров

How best to handle large buffers in a layered protocol stack?

I am working on a simple protocol stack for a small embedded system (multidrop, rs485 type stuff). In this stack, losely models after OSI layers: Application Network Datalink physical (serial driver) Each layer has its own header / footer portion that wraps the payload of the layer above it....

0
голосов
3ответов
283 просмотров

Buffers and bytes?

Could someone explain to me the uses of using buffers, and perhaps some simple (documented) examples of a buffer in use. Thanks. I lack much knowledge in this area of Java programming, so forgive me if I asked the question wrong. :s

2
голосов
5ответов
1961 просмотров

Java - is it possible to read a file line by line, stop, and then immediately start reading bytes where I stopped?

I'm having an issue trying to parse the ascii part of a file, and once I hit the end tag, IMMEDIATELY start reading in the bytes from that point on. Everything I know in Java to read off a line or a whole word creates a buffer, which ruins any chance of getting the bytes immediately following my ...

4
голосов
2ответов
2150 просмотров

Does a Java Scanner implicitly create a buffer even if you do not pass it one?

If I have the following example file where each number is represents a byte (123 has bytes 1, 2, and 3): 123456789 Let's say I create a FileInputStream. This reads in the binary byte by byte. So .read() returns 1, then 2, etc. Now let's say I create a buffer. The initial chunk it reads in (if ...

2
голосов
2ответов
5308 просмотров

GNU Screen: Environment variables

[Updated] The question is related to the questions GNU Screen: Programmers quotes in Readbuf and GNU Screen: files to numbered buffers?. Since they are not solved, the question targets more general concept about environment variables. My belief is that they are the key to make Screen more efficie...

1
голосов
1ответов
303 просмотров

GNU Screen: files to numbered buffers?

I unefficiently use "^a + ESC SPACE -- SPACE" and "^a + ]". 1. How can I copy a big file to GNU Screen buffer like ^a + : cat big_file > new_buffer ^a + : new_buffer ] 2. How can specify the number for each buffer like ^a + : cat big_file 2> new_buffer_number_2 ^a + 2]