kwenzh commented on code in PR #3635:
URL: https://github.com/apache/avro/pull/3635#discussion_r2734506487


##########
lang/c/src/io.c:
##########
@@ -274,6 +274,20 @@ int avro_read(avro_reader_t reader, void *buf, int64_t len)
        return EINVAL;
 }
 
+
+int64_t avro_max_read(avro_reader_t reader)
+{
+       if (is_memory_io(reader)) {
+               struct _avro_reader_memory_t *mem_reader = 
avro_reader_to_memory(reader);
+               return mem_reader->len - mem_reader->read;
+       } else if (is_file_io(reader)) {
+               struct _avro_reader_file_t *file_reader = 
avro_reader_to_file(reader);
+               return bytes_available(file_reader);

Review Comment:
   sorry, I haven't found a way to get the remaining buffer length for file 
I/O.  My goal is to check the maximum readable length before malloc to avoid 
memory leaks caused by the length exceeding the limit during avro_read_memory 
checks.   Are there any other good solutions?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to