git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/2] commit-slab: document clear_$slabname()

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Nov 25, 2013, 20:24 UTC
Message-ID
<20131125202409.GO4212@google.com>
In-Reply-To
<7f773c5c5ea16b19840f67ba99961be132940d32.1385405977.git.tr@thomasrast.ch>
Thomas Rast wrote:
> The clear_$slabname() function was only documented by source code so
> far.  Write something about it.
Good idea.
[...]
Show 10 quoted lines
> --- a/commit-slab.h
> +++ b/commit-slab.h
> @@ -24,6 +24,10 @@
>   *   to each commit. 'stride' specifies how big each array is.  The slab
>   *   that id initialied by the variant without "_with_stride" associates
>   *   each commit with an array of one integer.
> + *
> + * - void clear_indegree(struct indegree *);
> + *
> + *   Free the slab's data structures.

Tense shift (previous descriptions were in the present tense, while this one is in the imperative).

More importantly, this doesn't answer the questions I'd have if I were in a hurry, which are what exactly is being freed (has the slab taken ownership of any memory from the user, e.g. when elemtype is a pointer?) and whether the slab needs to be init_ ed again.

Maybe something like the following would work?
	- void clear_indegree(struct indegree *);
	  Empties the slab.  The slab can be reused with the same
	  stride without calling init_indegree again or can be
	  reconfigured to a different stride by calling
	  init_indegree_with_stride.
	  Call this function before the slab falls out of scope to
	  avoid leaking memory.

Thanks, Jonathan

Previous: Thomas RastNext: Thomas Rast
Message 3 of 18 in “commit-slab cleanups”
  1. 0/2 commit-slab cleanupsThomas Rast, Nov 25, 2013
  2. 1/2 commit-slab: document clear_$slabname()Thomas Rast, Nov 25, 2013
  3. Jonathan NiederNov 25, 2013
  4. Thomas RastNov 29, 2013
  5. Junio C HamanoNov 25, 2013
  6. Eric SunshineNov 27, 2013
  7. 2/2 commit-slab: declare functions "static inline"Thomas Rast, Nov 25, 2013
  8. Junio C HamanoNov 25, 2013
  9. Thomas RastNov 25, 2013
  10. commit-slab: declare functions "static inline"Thomas Rast, Nov 25, 2013
  11. Jonathan NiederNov 25, 2013
  12. Thomas RastNov 25, 2013
  13. Jonathan NiederNov 25, 2013
  14. Junio C HamanoNov 25, 2013
  15. Junio C HamanoNov 25, 2013
  16. Duy NguyenDec 1, 2013
  17. commit-slab: sizeof() the right type in xreallocThomas Rast, Dec 1, 2013
  18. Jeff KingDec 2, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.