Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please code it in c language bPointer Create(short size, char increment, char mode) TODO202 (function header) and TODO203 (function definition). This function creates a new

please code it in c language image text in transcribed
bPointer Create(short size, char increment, char mode) TODO202 (function header) and TODO203 (function definition). This function creates a new buffer in memory (on the program heap), trying to allocate memory for one buffer structure using calloc(); It tries to allocates memory for one dynamic character buffer (content) calling malloc() with the given initial capacity (size): This function also copies the given size value into the Buffer structure size variable; NOTE_06: The range of the parameter size must be between o and the MAXIMUM ALLOWED POSITIVE VALUE - 1 inclusive. The maximum allowed positive value is determined by the data type of the parameter size. NOTE_07: The range of the parameter increment can vary according to the For FIXMODE, the increment must be always 0. mode: Algonquin College - Compilers: CST8152 - Assignment 1 Specification - Winter, 2021 For ADDMODE the values acceptable are from the range 1 to 255. For MULMODE, the values go from 1 to MAX_INCREMENT(100) inclusive. of the size is 0, the function tries to create a character buffer with size adjusted to DEFAULT_SIZE (200) characters and increment to DEFAULT_INCREMENT (15). According to the mode parameter (char), the buffer mode is set (use the constant definitions for this): FIXMODE (O), ADDMODE (1), MULMODE (-1). . In the FIXMODE, there is no increment applicable. With the correct size, the content of buffer (char*) can be created using malloc(). This function also sets the Buffer structure operational mode indicator mode and the increment. It also sets the flags field to its default value which is 3FFF hexadecimal (0011.1111.1111.1111 in binary). Finally, on success, the function returns a pointer to the Buffer structure. It must return NULL pointer on any error which violates the constraints imposed upon the buffer parameters or prevents the creation of a working buffer. Error Condition_01: If run-time error occurs, the function must return immediately after the error is discovered. Check for all possible errors which can occur at run time. Do not allow "memory leaks", "dangling" pointers, or "bad parameters bPointer Create(short size, char increment, char mode) TODO202 (function header) and TODO203 (function definition). This function creates a new buffer in memory (on the program heap), trying to allocate memory for one buffer structure using calloc(); It tries to allocates memory for one dynamic character buffer (content) calling malloc() with the given initial capacity (size): This function also copies the given size value into the Buffer structure size variable; NOTE_06: The range of the parameter size must be between o and the MAXIMUM ALLOWED POSITIVE VALUE - 1 inclusive. The maximum allowed positive value is determined by the data type of the parameter size. NOTE_07: The range of the parameter increment can vary according to the For FIXMODE, the increment must be always 0. mode: Algonquin College - Compilers: CST8152 - Assignment 1 Specification - Winter, 2021 For ADDMODE the values acceptable are from the range 1 to 255. For MULMODE, the values go from 1 to MAX_INCREMENT(100) inclusive. of the size is 0, the function tries to create a character buffer with size adjusted to DEFAULT_SIZE (200) characters and increment to DEFAULT_INCREMENT (15). According to the mode parameter (char), the buffer mode is set (use the constant definitions for this): FIXMODE (O), ADDMODE (1), MULMODE (-1). . In the FIXMODE, there is no increment applicable. With the correct size, the content of buffer (char*) can be created using malloc(). This function also sets the Buffer structure operational mode indicator mode and the increment. It also sets the flags field to its default value which is 3FFF hexadecimal (0011.1111.1111.1111 in binary). Finally, on success, the function returns a pointer to the Buffer structure. It must return NULL pointer on any error which violates the constraints imposed upon the buffer parameters or prevents the creation of a working buffer. Error Condition_01: If run-time error occurs, the function must return immediately after the error is discovered. Check for all possible errors which can occur at run time. Do not allow "memory leaks", "dangling" pointers, or "bad parameters

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_step_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions