stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Farid Zaripov" <>
Subject RE: svn commit: r421918 - in /incubator/stdcxx/trunk/tests: include/rw_alloc.h src/alloc.cpp
Date Mon, 17 Jul 2006 15:54:18 GMT

> -----Original Message-----
> From: Martin Sebor [] 
> Sent: Saturday, July 15, 2006 4:02 AM
> To:
> Subject: Re: svn commit: r421918 - in 
> /incubator/stdcxx/trunk/tests: include/rw_alloc.h src/alloc.cpp
> Instead of _rw_binary_search/_rw_lower_bound, would it be 
> possible to use the standard C function bsearch()?
  The bsearch() potentially can work slower than _rw_binary_search
because of call of compare function which is not inlined.
  Anyway _rw_lower_bound is needed for finding the insertion place
of the new item (_rw_table_insert).

> The error handling in the file isn't very robust: we 
> shouldn't just assert that the system calls succeeded; we 
> should print out an error message and either exit with a 
> non-zero exit status or return a value indicating a failure 
> (if possible). If the former, the mechanism to use is 
> rw_error() and/or rw_fatal(). The %m and %{#m} directives let 
> you format the text of the error message corresponding to the 
> value of errno and the name of the EXXX variable, respectively.
  Done. The diff file is attached.

> Finally, I'm not sure I understand the purpose of the 
> MemRWGuard class. The ctor sets one kind of permissions on a 
> page of memory and the dtor sets another. Some functions do 
> things in between the invocations of the two, others don't. 
> It's not clear to me whether all invocations of the ctor and 
> dtor really need the dtor to run or not. In other words, it's 
> not clear to me that plain old functions wouldn't be more 
> appropriate. Can you shed some light on this?

  The MemRWGuard is scope guard class. The dynamic memory, used for
rw_alloc ()
is read-only the most of time (to prevent from the user modification).
When rw_alloc ()
inserts the new item to the list of BlockInfo or to table of Pair it is
needed to set the r/w
access before the insertion and then restore access to the r/o. The
MemRWGuard does this.

  The mprotect() requires address aligned to the memory page boundary
and additional task
of the MemRWGuard constructor is recalculation of the passed address and
size considering
the alignment.


  • Unnamed multipart/mixed (inline, None, 0 bytes)
View raw message