Is there a way to have a pointer to a bucket? (C / C ++)

Is there a way to have a pointer to a bitvek?

Many IO system calls (in particular, connection-related) return data to a buffer of a certain size. There is a trick or way to point to a sorting bucket, so I can accept any amount of data to be thrown. Doing something like "char tmp [INT_MAX]" is crazy. The behavior I was looking for is something like / dev / null, only in the world of pointers.

Do not hope so .... just curious.

Thanks Chenz

UPDATE: Maybe mmap-ing / dev / null. I forgot about it when I asked a question.

+3
source share
7

IO ? FILE (fopen, fread ..), . - C/++, , , , , , . , ?

+2

, - . - , , CPU .

+1

, . mmaping/dev/null WELL , . , , .

+1

- ( ) .

, .

, .

, , . , . , ( ) , .

, NULL.

0

. , . , , , - , .

, API, , , no-op.

0

, , .

0

The only way I came up with was to write some kind of system call that would switch all the virtual memory in the program to another psuedo software virtual memory space. But the psuedo memory space would be recorded only and never stored. Then you will switch the virtual memory space when you finish writing the "NULL" pointer.

Example:

  main() 
  {
    int fd = open("file", O_RDONLY);
    null_vm();
    read(fd, NULL, UINT_MAX);
    unnull_vm();
    close(fd);
    return;
  }

Thanks Chenz

0
source

Source: https://habr.com/ru/post/1742667/


All Articles