Subversion Repositories QNX 8.QNX8 IFS tool

Rev

Rev 16 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 16 Rev 26
Line 338... Line 338...
338
      reallocated_ptr = realloc (buffer->bytes, write_index + data_size + sizeof (size_t)); // always null-terminate buffers, but never report the null terminator
338
      reallocated_ptr = realloc (buffer->bytes, write_index + data_size + sizeof (size_t)); // always null-terminate buffers, but never report the null terminator
339
      if (reallocated_ptr == NULL)
339
      if (reallocated_ptr == NULL)
340
         return (0); // on failure, return an error value (errno already set to ENOMEM)
340
         return (0); // on failure, return an error value (errno already set to ENOMEM)
341
 
341
 
342
      buffer->bytes = reallocated_ptr; // save pointer to reallocated data
342
      buffer->bytes = reallocated_ptr; // save pointer to reallocated data
-
 
343
      if (write_index > buffer->size)
343
      memset (&buffer->bytes[buffer->size], 0, write_index - buffer->size); // buffer was upsized: fill the upsized part with zeroes up to write_index
344
         memset (&buffer->bytes[buffer->size], 0, write_index - buffer->size); // buffer was upsized: fill the upsized part with zeroes up to write_index
344
   }
345
   }
345
 
346
 
346
   if (data_size > 0)
347
   if (data_size > 0)
347
      memcpy (&buffer->bytes[write_index], data, data_size); // write data in place
348
      memcpy (&buffer->bytes[write_index], data, data_size); // write data in place
348
 
349