Completed

Change simple C functions from file I/O to memory buffer I/O

This project was successfully completed by marcnabillabib for $30 USD in a day.

Get free quotes for a project like this
Employer working
Completed by:
Project Budget
$30 - $250 USD
Completed In
1 day
Total Bids
15
Project Description

SUMMARY:

I have a simple C demo of six small functions. However, they currently work by read/writing 1 byte at a time from a _file_, not memory ...

I need you to get rid of all _file_ related code and change it so it reads/writes from an existing _memory_ buffer instead of from the file, very simple if you're good with C but I'm too new to C to figure it out in a decent time frame!

THE SOURCE CODE:

.c source - [url removed, login to view]

.h header - [url removed, login to view]

____________________________________

SPECIFICS:

- the function "open_input_bitstream(const char *path)" will change so that it accepts 1) the address of a buffer, and 2) size of buffer. (The buffer is provided/pre-allocated by the user)

- the function "open_output_bitstream(const char *path)" will change so that it accepts just 1) size of buffer. It creates/allocates the buffer using the specified size.

- close_bitstream() will no longer close the file handle. Instead it will free the memory allocated during open_output_bitstream()

- the getbits/putbits functions obviously change - instead of reading/writing from the file, the memory buffer is used instead - no files.

- when writing (ie. putbits), if we end up writing up to the end of the buffer the buffer should be realloc'd with (at least) another 4096 bytes, so writing continues uninterrupted.

- when reading (ie. getbits), change the EOF check so that the buffer size is used instead, to prevent reading beyond the buffer

- the bitstream structure currently starts with "FILE *stream", so this element will either be deleted or replaced with a buffer pointer or something along those lines.

Please keep in mind performance is important.

Looking to make some money?

  • Set your budget and the timeframe
  • Outline your proposal
  • Get paid for your work

Hire Freelancers who also bid on this project

    • Forbes
    • The New York Times
    • Time
    • Wall Street Journal
    • Times Online