Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8696021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:10:49+00:00 2026-06-13T01:10:49+00:00

The structure of the program is as such, there is a header file manager.h

  • 0

The structure of the program is as such, there is a header file manager.h in which C++ class is defined with data members and member functions. Then in a manager.C file the member functions are implemented.

I’ve defined 3 structs in the .c file.

#define HTSIZE 7

struct Node
{
int value;
int page;   
struct Node *next; 
};

struct Node *hashtable[HTSIZE];


struct lruNode{
int value;
struct lruNode *next;
struct lruNode* head;
struct lruNode* tail;

};

struct lruNode* lruhashtable[HTSIZE];
struct lruNode* lruTrackHead;
struct lruNode* lruTrackTail;


struct mruNode{
int value;
struct mruNode *next;    
 };

 struct mruNode* mruTrackHead=NULL;
 struct mruNode* mruhashtable[HTSIZE];

The data members of class are as follows:
Class Name:Page

Class Name:Frame

Class Name:Manager

All the structs are declared in manager.C

manager.h has the following data members.

Page* pagePool;
Frame* framePool;

In manager.C I’m defining them as

pagePool=new Page[n];
framePool=new Frame[n];

In the destructor for manager.C

I’m doing

delete[] pagePool;
delete[] framePool;
*hashtable=NULL;
*lruhashtable=NULL;
*mruhashtable=NULL;

The structs here are global and not part of the class as such. This is part of my homework. The problem is in my test-cases I’m carry forwarding the previous test case values.

I did an edit to set the pointers the way they are. Now the first value in the array for all array of pointers to struct is null.

Still the array of pointers to objects are not freed up. Can someone comment on that?

Edit

On iterating through a loop, the pointers are freed.

But still the array of pointers to objects are not?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T01:10:51+00:00Added an answer on June 13, 2026 at 1:10 am

    when you call

    free(hashtable);

    you dealocate memory alocated for an array of

    int value;
    int page;   
    struct Node *
    

    but the memory alocated for structure that is pointed by Node is note dealocated.

    The main idea is to dealocate from the “deepest pointed” structure to top. So try to do a bottom up dealocation ,in reverse order that it was alocated.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There are many methods for representing structure of a program (like UML class diagrams
I have a speed critical multithreaded program which involves data in a tree structure.
I have the need to use a Stack-like data structure for a program that
Here is the example with comments: class Program { // first version of structure
Say I have a Group data structure which contains a list of Element objects,
I'm currently trying to develop a program which stores lots of data, similar to
I have a program structure like following : int firstFunction(unsigned char *firstValue, int s,
Code first: '''this is main structure of my program''' from twisted.web import http from
My problem is to send a structure between a program in C to a
Here is a structure used in a program: struct basic_block { void * aux;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.