char doubleIt (char **arr, int *maxsize); The doubleIt function will increase the heap size by doubling the original space. The functions takes 2 arguments: 1. A double pointer of type char called arr. This is a 2D dynamic array that contains words (strings) from the respective category (noun, verb, adjective, preposition). This is the original heap. 2. A pointer of type int called maxsize. This pointer holds the address of an integer that keeps track of the maximum amount of strings the 2D dynamic array can store. When this function is invoked, the current size of the dynamic array is at capacity so the values should match. This value will need to be multiplied by 2. The function allocates a new heap that is twice the size of the original heap and copy the values from the original heap into the new heap. One important note about this is that you have to properly copy the values over in order to avoid segmentation fault. Think about how this can be avoided. That is part of the challenge of this assignment. Avoid using realloc, calloc, or any sort of other memory function except for malloc and free. If any other built in memory function is used then the ones stated will result in points being deducted!
char doubleIt (char **arr, int *maxsize); The doubleIt function will increase the heap size by doubling the original space. The functions takes 2 arguments: 1. A double pointer of type char called arr. This is a 2D dynamic array that contains words (strings) from the respective category (noun, verb, adjective, preposition). This is the original heap. 2. A pointer of type int called maxsize. This pointer holds the address of an integer that keeps track of the maximum amount of strings the 2D dynamic array can store. When this function is invoked, the current size of the dynamic array is at capacity so the values should match. This value will need to be multiplied by 2. The function allocates a new heap that is twice the size of the original heap and copy the values from the original heap into the new heap. One important note about this is that you have to properly copy the values over in order to avoid segmentation fault. Think about how this can be avoided. That is part of the challenge of this assignment. Avoid using realloc, calloc, or any sort of other memory function except for malloc and free. If any other built in memory function is used then the ones stated will result in points being deducted!
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
I start with the code but I have a hard time just figure out the whole malloc process
Expert Solution
Step 1
In C, we utilize the free function to release memory (). The only argument to the free() function is a reference towards the memory you want to free. All memory was also allocated previously with malloc(), free(equivalent. )'s ().
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education