unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* String allocation
@ 2011-11-13  6:01 qiang
  2011-11-13  6:42 ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: qiang @ 2011-11-13  6:01 UTC (permalink / raw)
  To: emacs-devel


Thanks to all of you. Reading source code is such an experience for
me, both painful and yet enjoyable. 

Since we are talking about strings, can I ask another obstacle I met. I
know when allocating string objects, emacs will retrieve one from a
string_block struct. My question is how this string_free_list works ?
where does it point to ? How it becomes a list ? Especially I'm puzzled
by this macro

#define NEXT_FREE_LISP_STRING(S) (*(struct Lisp_String **) (S))

I understand S is a pointer to a Lisp_String, how can the following code
construct a free_list ?

for (i = STRING_BLOCK_SIZE - 1; i >= 0; --i)
	{
	  s = b->strings + i;
	  NEXT_FREE_LISP_STRING (s) = string_free_list;
	  string_free_list = s;
	}

Regards
Qiang




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: String allocation
  2011-11-13  6:01 String allocation qiang
@ 2011-11-13  6:42 ` Eli Zaretskii
  2011-11-13  7:05   ` Qiang Guo
  0 siblings, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2011-11-13  6:42 UTC (permalink / raw)
  To: qiang; +Cc: emacs-devel

> From: qiang <qguo@ualberta.ca>
> Date: Sat, 12 Nov 2011 23:01:50 -0700
> 
> #define NEXT_FREE_LISP_STRING(S) (*(struct Lisp_String **) (S))
> 
> I understand S is a pointer to a Lisp_String, how can the following code
> construct a free_list ?
> 
> for (i = STRING_BLOCK_SIZE - 1; i >= 0; --i)
> 	{
> 	  s = b->strings + i;
> 	  NEXT_FREE_LISP_STRING (s) = string_free_list;
> 	  string_free_list = s;
> 	}

After this loop is done, what will be in each element of the array
b->strings?



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: String allocation
  2011-11-13  6:42 ` Eli Zaretskii
@ 2011-11-13  7:05   ` Qiang Guo
  2011-11-13  7:57     ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: Qiang Guo @ 2011-11-13  7:05 UTC (permalink / raw)
  To: emacs-devel


pointer to the next slot in b->strings ?




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: String allocation
  2011-11-13  7:05   ` Qiang Guo
@ 2011-11-13  7:57     ` Eli Zaretskii
  2011-11-13  8:32       ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2011-11-13  7:57 UTC (permalink / raw)
  To: Qiang Guo; +Cc: emacs-devel

> From: Qiang Guo <qguo@ualberta.ca>
> Date: Sun, 13 Nov 2011 00:05:54 -0700
> 
> 
> pointer to the next slot in b->strings ?

Which is another way of saying "linked list".



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: String allocation
  2011-11-13  7:57     ` Eli Zaretskii
@ 2011-11-13  8:32       ` Eli Zaretskii
  0 siblings, 0 replies; 5+ messages in thread
From: Eli Zaretskii @ 2011-11-13  8:32 UTC (permalink / raw)
  To: qguo, emacs-devel

> Date: Sun, 13 Nov 2011 02:57:28 -0500
> From: Eli Zaretskii <eliz@gnu.org>
> Cc: emacs-devel@gnu.org
> Reply-To: Eli Zaretskii <eliz@gnu.org>
> 
> > From: Qiang Guo <qguo@ualberta.ca>
> > Date: Sun, 13 Nov 2011 00:05:54 -0700
> > 
> > 
> > pointer to the next slot in b->strings ?
> 
> Which is another way of saying "linked list".

And more importantly, this explains why NEXT_FREE_LISP_STRING is
called like that.



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-11-13  8:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-13  6:01 String allocation qiang
2011-11-13  6:42 ` Eli Zaretskii
2011-11-13  7:05   ` Qiang Guo
2011-11-13  7:57     ` Eli Zaretskii
2011-11-13  8:32       ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).