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

  • SEARCH
  • Home
  • 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 8898629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:39:32+00:00 2026-06-15T00:39:32+00:00

I am trying to create a free list to implement a heap allocator. Here

  • 0

I am trying to create a free list to implement a heap allocator. Here is how I defined the struct so far:

typedef struct headerT headerT;

struct headerT{
   size_t payloadSize;
   struct headerT* next; // unused field to make struct 8 bytes, simplifies alignment                                      
};

headerT* freeList;

and here is how I initialize my heap:

int myinit()
{
  freeList = InitHeapSegment(0); // InitHeapSegment resets heap segment to empty, no pages                                                  
                              //allocated                                                                             
  freeList->payloadSize = 0;
  freeList->next=NULL;
  return 0;
}

I get a segfault immediately when the function tries to change the payload size to zero. What am I missing here?

  • 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-15T00:39:33+00:00Added an answer on June 15, 2026 at 12:39 am

    The problem is here:

     freeList = InitHeapSegment(0); // InitHeapSegment resets heap segment to empty, no pages                                                  
                                  //allocated     
    

    You say that InitHeapSegment “resets” heap segment to empty, but no pages are allocated. Probably its not malloc()ing. Hence freeList could point to a junk value which you do not have the permission to access, giving you a SIGSEGV or SEGMENTATION VIOLATION error. In Windows, this error is of type Cx00000005

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

Sidebar

Related Questions

I'm trying to create a graceful, distraction-free text editor. One of the features I
Ok so I am trying create a login script, here I am using PHP5
I am trying to create a scrollable menu list in JavaScript and I am
I am trying to create a function that deletes an entire list, but I
I'm trying to create an access control system. Here's a stripped down example of
I am trying to create a generic list class for use with tiOPF (an
Hello I am trying to free a linked list I have created and I'm
I'm trying to create a dynamic array in my List class that will start
I am trying to create 2 versions of an Android app (free/paid). I have
I'm trying create a bot which automatically likes Facebook posts. Using Mechanize I can

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.