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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:17:00+00:00 2026-05-13T21:17:00+00:00

The following code snippet is from The Official GNOME 2 Developer’s Guide : GMemChunk

  • 0

The following code snippet is from The Official GNOME 2 Developer’s Guide:

GMemChunk my_chunk;
my_chunk = g_mem_chunk_new("My Chunk",
                           42,
                           42*16,
                           G_ALLOC_AND_FREE);
gchar *data[50000];
gint i;

/* allocate 40,000 atoms */
for(i = 0; i < 40000; i++)
{
   data[i] = g_mem_chunk_alloc(my_chunk);
}
  • Does this mean every atom is of 42 bytes, each “memory chunk” contains 42 16 atoms, and 40000/16=2500 memory chunks will be created when the above code is run?

  • Why are they using gchar* here? Does an implicit cast from gpointer (void*) to gchar* take place when data[i] = g_mem_chunk_alloc(my_chunk); is run?

  • If the above statement is true then each gchar* points to 42 bytes of memory. How do I access all the bytes of a particular atom, then? Will data[7]+41 be a usable memory location?


  • When I try to compile the code gcc produces this error message:

    error: storage size of ‘my_chunk’ isn’t known
    What’s wrong?

  • 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-05-13T21:17:01+00:00Added an answer on May 13, 2026 at 9:17 pm

    In order of your questions:

    • Each memory block contains 16 atoms, but other than that, yes.
    • Yes, void * can be implicitly converted to any other pointer type in C, and this is typically considered to be good C style. They are using gchar * here because they apparently want to treat each atom as an array of 42 gchars.
    • Yes, data[7][41] is the last accessible byte of the 8th atom.
    • The error is because the declaration of my_chunk is wrong (GMemChunk is an opaque type that shouldn’t be directly instantiated in your code). The declaration should be:

      GMemChunk *my_chunk;

    as per the signature of g_mem_chunk_new() and g_mem_chunk_alloc().

    By the way, the Glib documentation states that the Chunk allocator is deprecated, and you should use the slice allocator instead.

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

Sidebar

Ask A Question

Stats

  • Questions 516k
  • Answers 516k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Originally, apps did continue while menus were open. It was… May 16, 2026 at 6:41 pm
  • Editorial Team
    Editorial Team added an answer It looks like the GD library is not installed. Are… May 16, 2026 at 6:41 pm
  • Editorial Team
    Editorial Team added an answer I understood that you'd like to have a special column… May 16, 2026 at 6:41 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Given the following code snippet from inside a method; NSBezierPath * tempPath = [NSBezierPath
The following code snippet is from book Effective C#, public event AddMessageEventHandler Log; public
The following code snippet is from the Silverlight SDK and I am trying to
Consider the following code snippet from .NET 4.0 library: private T[] array; private static
The following R code generates a snippet from data frame I am working with
CREATE TABLE DIALOGUE_TABLE(EXPIRE_TIME TIMESTAMP); Following code snippet is inside stored proc : PO_EXPIRETIME :-
I have the following snippet of code of which I do not have access
I have the following code in my microcontroller project: if (newThrottle < currentThrottle) {
this is my code snippet, where the program doesn't enter the foreach loop: var
I m trying to delete a record from a SQLiteDB via Android Application,This is

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.