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.
Try it now!
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
Custom Writings Help is a Quality-Oriented Company in Online Writing as a result of hiring exceptional professionals to execute clients' tasks.
Essays
At Custom Writings Help,We understand the struggle of research paper writing, and that is why at Custom WritingS Help, we are all out to help you. We pride ourselves on having a team of clinical writers. The stringent and rigorous vetting process ensures that only the 'BEST' Writers are chosen for the job. We have highly qualified Ph.D. and MA writers working with us; we equally offer these experienced writers specific bonuses and incentives to make them deliver highly original, unique, and informative content at reasonably low prices.
Admissions
Thesis Writing Service
Worlwide, Many Masters Students are struggling with Thesis Completion. A thesis is likely to be the longest and most challenging piece of work a student has ever completed. However, unlike essays and other assignments, a student can pick a particular interest topic and work on their initiative. Fortunately, we are there for you. At Custom Writings Help, you are assured of an authentic, imaginative, informative, linguistically great, and advantageous thesis that adheres to all your needs. So, why continue considering different writers when you have discovered the best in the field?
Editing
Custom Papers
Not a single student can avoid writing custom papers. However, a total lack of experience, skills, and time makes it very hard to produce a superb writing piece. Therefore, if you are seeking professional help, turn to us. Our specialized and experienced writers compose a variety of model papers, including custom essays, college term papers, research papers, book reports, MBA essays, executive summaries, dissertations, Ph.D. theses, admission essays, and research proposals for college and university students at any level.
Coursework
Essay Writing
Most of the students disregard the critical principles of essay writing and compose papers below sensible guidelines. Therefore, with Custom Writings Help, one should not worry about his/her essay. Our Writers compose informative and engaging content on all complexities and topics. We write meaningful and smart essays while prioritizing all aspects that bring about a good grade, such as impeccable grammar, proper structure, zero-plagiarism, and conformance to guidelines.
Coursework
Coourse Work Writing
Don't let the seemingly never-ending onslaught of writing assignments get you down. If you are looking where to get course work assistance online, the writers at Custom Writings Help are here to assist you with all of your writing needs. We undertake to unique delivery of papers that meet the professor's requirements. The content is proofread, edited, and checked plagiarism before submission to customers. No matter how big or small your work is, we will deliver on time. Try US Now! !
Coursework
Dissertation Writing Service
High-Quality Dissertation Writing Services are rare. They require Ph.D. academicians – not easily found. However, are an exception. The years, time, and resources we have invested in the dissertation world has given us a competitive advantage over others. Choose to come to Custom Writings Help; You will find perfect Ph.D. consultants who have written hundreds of dissertations theses ready to help you. Let our dissertation-writing services help you craft your dissertation, for you are assured we will give you the results.