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.

Calculate your paper price
Pages (550 words)
Approximate price: -

Why Choose Us

Quality Papers

We value our clients. For this reason, we ensure that each paper is written carefully as per the instructions provided by the client. Our editing team also checks all the papers to ensure that they have been completed as per the expectations.

Professional Academic Writers

Over the years, our Acme Homework has managed to secure the most qualified, reliable and experienced team of writers. The company has also ensured continued training and development of the team members to ensure that it keep up with the rising Academic Trends.

Affordable Prices

Our prices are fairly priced in such a way that ensures affordability. Additionally, you can get a free price quotation by clicking on the "Place Order" button.

On-Time delivery

We pay strict attention on deadlines. For this reason, we ensure that all papers are submitted earlier, even before the deadline indicated by the customer. For this reason, the client can go through the work and review everything.

100% Originality

At Essay USA, all papers are plagiarism-free as they are written from scratch. We have taken strict measures to ensure that there is no similarity on all papers and that citations are included as per the standards set.

Customer Support 24/7

Our support team is readily available to provide any guidance/help on our platform at any time of the day/night. Feel free to contact us via the Chat window or support email:

Try it now!

Calculate the price of your order

We'll send you the first draft for approval by at
Total price:

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

Our Services

Essay USA has stood as the world’s leading custom essay writing services providers. Once you enter all the details in the order form under the place order button, the rest is up to us.


Essay Writing Services

At Essay USA, we prioritize on all aspects that bring about a good grade such as impeccable grammar, proper structure, zero-plagiarism and conformance to guidelines. Our experienced team of writers will help you completed your essays and other assignments.


Admission and Business Papers

Be assured that you’ll definitely get accepted to the Master’s level program at any university once you enter all the details in the order form. We won’t leave you here; we will also help you secure a good position in your aspired workplace by creating an outstanding resume or portfolio once you place an order.


Editing and Proofreading

Our skilled editing and writing team will help you restructure you paper, paraphrase, correct grammar and replace plagiarized sections on your paper just on time. The service is geared toward eliminating any mistakes and rather enhancing better quality.


Technical papers

We have writers in almost all fields including the most technical fields. You don’t have to worry about the complexity of your paper. Simply enter as much details as possible in the place order section.