change the child process io buffer to use heap memory
This commit is contained in:
parent
5f645c1ea5
commit
072a356d72
17
src/main.c
17
src/main.c
|
|
@ -69,11 +69,17 @@ size_t getuserinput(char* input_buffer, size_t max_buffer_size, int fd) {
|
|||
|
||||
// go through the buffer and find the lines to be edited and print them after
|
||||
int processbufferpop(char *roll_buffer, size_t read_length) {
|
||||
//this is where some optimization could come in with using malloc and then freeing subset of memory; dog garn dynamic memory allocation
|
||||
int found_index;
|
||||
char *found_char = strchr(roll_buffer, '\n');
|
||||
if (found_char != NULL){
|
||||
found_index = found_char - roll_buffer;
|
||||
char to_process_string[];
|
||||
|
||||
/*for (int i; i<= read_length; i++){
|
||||
if (roll_buffer[i] = '\n'){
|
||||
}
|
||||
}*/
|
||||
} else {
|
||||
//no more instances
|
||||
|
||||
}
|
||||
|
||||
write(STDOUT_FILENO, roll_buffer, read_length);
|
||||
write(STDOUT_FILENO, "\n", 1);
|
||||
|
|
@ -107,8 +113,9 @@ int main(int argc, char *argv[]) {
|
|||
}
|
||||
|
||||
//remainder is main is the parent process for processing input and shit
|
||||
char child_out_roll_buffer[BUFCHUNKSIZE+BUFSAFEPAD] = {0};
|
||||
fcntl(master, F_SETFL, O_NONBLOCK);
|
||||
char *child_out_roll_buffer = (char*) malloc(sizeof(char) * (BUFCHUNKSIZE+BUFSAFEPAD+1));
|
||||
|
||||
usleep(500*1000);
|
||||
while(1){
|
||||
// ideally I would want to read from the pipe and buffer the output, rewriting the line on change
|
||||
|
|
|
|||
Loading…
Reference in New Issue