You may assign the value o to the elements

You may assign the value o to the elements in your array to initialize the elements — whether you are creating the array or appending to the array. 0 will indicate an “empty” element. • Recall, in pre-allocation, we allocate more space in memory than what is requested by the user. rows and cols are the number of rows and columns the user has requested for in their 2D matrix. For example, if rows is 10 and cols is 10, and the user appends a value such that the number of rows increase by one, then you increase rows to 11. o reserved_rows and reserved_cols are the number of rows and columns that are reserved for the user i.e. this is the capacity of your 2D array. For example, currently, the rows and reserved_rows are 10 and cols and reserved_cols are 10. If the user appends a value such that the number of rows should increase, then you increase rows to 11 and double the size of reserved_rows to 20 along with the number of rows allocated in memory for your 2D array. Review preallocation for more details. These functions would work around the following user defined data structures (see toimgr.h): /* Structure type that encapsulates our image: 2D array. * the rows represent the indices of the main array, * the cols represent the indices of the arrays pointed to by the pointers * in the elements of the main array. */ typedef struct { uint8_t** pixels; unsigned int rows; unsigned int cols; unsigned int reserved_rows; unsigned int reserved_cols; } imgr_t; /* A type for returning status codes */ typedef enum { IMGR_OK, IMGR_BADCOL, IMGR_BADROW, IMGR_BADALLOC, IMGR EMPTY } imgr_result_t; HINTS • Don’t forget to keep adding appropriate function calls to your test driver as you go along. reserved_rows should always represent the amount of memory allocated to all the row arrays in imgr_t. This means that if you doubled the length of one row, you need to do the same for all other rows. reserved_cols should always represent the amount of memory allocated to the main col array. This means that if you double your original array, you also need to double the amount of rows you have in imgr_t. TESTING: you can test your program by running: $ make to # OR gcc -Werror -Wfatal-errors -g -o to to.c toimgr.c (see Makefile) $ ./to (see? Makefiles saves your gcc command so you don’t have to type this long thing over and over again, convenient huh :D) The following is a breakdown of the tasks. REMINDER: • write comments!! Test and debug your code! Prompt the user for what they should enter by printing messages with printf , e.g. “Enter an integer: “, and let the user know what the output is by printing a message, e.g. “Here is the result: Task 01.1 REQUIREMENT: write a function in toimgr.c with the following declaration: imgr_t* imgr_create(unsigned int rows, unsigned int cols); • INPUT: the number of rows and cols of the desired array. • OUTPUT: ingr_create() returns the POINTER to a new instance of data structure imgr_t. • BEHAVIOUR: if malloc() fails (i.e. returns NULL ), imgr_create() returns NULL . o The reserved_rows and reserved_cols should be initialized to be the same as rows and cols respectively. These fields represent the capacity or the available space in your 2D array. In the front end, the user should not have to deal with this. You use them in your functions to perform preallocation. Task 01.2 REQUIREMENT: write a function in toimgr.c with the following declaration: void imgr_destroy(imgr_t* im); • INPUT: the pointer of a imgr_t variable im. • BEHAVIOUR: ingr_destroy() should free() the memory allocated to im.

Place your order
(550 words)

Approximate price: $22

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
$26
The price is based on these factors:
Academic level
Number of pages
Urgency
Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read more

Privacy policy

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more