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 8450963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:06:41+00:00 2026-06-10T11:06:41+00:00

Am trying to build a memory suballocator. I’ve some errors with the code bellow,

  • 0

Am trying to build a memory suballocator. I’ve some errors with the code bellow, it tells me that:

free_list_ptr->next = &firstByte;
free_list_ptr->prev = &firstByte;

am getting gcc error warnings of warning: assignment from incompatible pointer type

//primitive variable of byte as char, always positive.
typedef unsigned char byte;
static byte *memory = NULL;

struct header;

typedef struct _header {
    int signiture;
    int size;
    struct header* next;
    struct header* prev;
} header;


static header *free_list_ptr;


void allocator_init(u_int32_t size){

    memory = (byte*) malloc(size);

    //initialize free_list_ptr;
    free_list_ptr = (header*) memory;

        header* firstByte = (header*) memory;

    free_list_ptr->size = size;

    //error here: warning: assignment from incompatible pointer type
    free_list_ptr->prev = &firstByte;
    free_list_ptr->next = &firstByte;
}
  • 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-10T11:06:43+00:00Added an answer on June 10, 2026 at 11:06 am

    This is most probably wrong:

    struct header;               // forward declare "struct header"
    
    typedef struct _header {
        int signiture;
        int size;
        struct header* next;     // refer to the forward declared "struct header"
        struct header* prev;
    } header;                    // declare type-alias "header"
    

    do instead

    typedef struct header header; // forward declaration of both
    
    struct header {
        int signiture;
        int size;
        header* next;
        header* prev;
    };
    

    In C struct header and the typedefed header live in two different name spaces. You forward declared struct header but you never defined it.

    Also, identifiers starting with _ are usually reserved for internals, so you shouldn’t use them for your own stuff.

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

Sidebar

Related Questions

I'm trying to build an application that has two process that uses Shared memory
trying to test out move semantics i build a simple class that allocates some
I'm trying to build a client server application using POSIX shared memory and POSIX
I'm trying build an App Engine connected Android application and am having some problems
Trying to build Xuggler under Windows. Xuggler is core native code functions wrapped into
I am trying to build a real-time web service that deals with dynamic 10k
I'm trying to build something (ultimately a gem but for now an application) that
I'm currently trying to build a code which is supposed to work on a
I'm trying to build a jQuery.live like function. Helper is a class that has
I am trying to build an array that contains arrays of dictionary objects in

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.