Reference counted dynamic byte array
This looks mostly good to me. Your code looks like fairly clean C. I have some comments:


I think capacity is a better name than capability.
I would avoid calling your header memory.h, since memory is a header in C++. Maybe checked_alloc.h instead? Also, include it as "memory.h" and let your build system figure out its path.
How is your error handling in the assert_...alloc functions? Do they just terminate the program?
Two of your public interface functions are without documentation. Are they not supposed to be part of the public interface? If not, put them in the implementation file (only) and make them static. If they are, document them as well.
Note that the assert() macro is only evaluated if your library is compiled without NDEBUG. This means that the code using it will be unchecked for production builds. It might be fine, but maybe you want checking in production as well; I'm just pointing it out.
As far as I can see, you adhere to the Linux coding style.
Consider typedef uint8_t byte or something like that to emphasize what the role of the uint8_ts are. Remember that you have no guarantee that CHAR_BIT is 8. (Maybe you want to use char instead, which is guaranteed to always be one byte.)
I would change if (a-&gt;length == a-&gt;capability) to if (a-&gt;length &gt;= a-&gt;capability). The latter is a bit clearer, and if you at one point allow adding larger objects the code will still work.
Your macro looks nasty.

I'd do:

#define CAPACITY_GROWTH_FACTOR 2

/* ... */

a-&gt;capability *= CAPACITY_GROWTH_FACTOR;


Or even better, change the #define into a const size_t.
The nmemb variable isn't very readable. Change it to num_members or something like that.
Consider sorting your #includes alphabetically.
While I don't see anything wrong with your reference counting, you should thoroughly test it to verify that it works.
Regarding reference counting and your interface, ask yourself these questions:


What happens when you copy your array? What do you want to happen? How should a copy be made?
How should copies behave when you modify an array that has multiple references to it?
Will this be used in a multi-threaded environment?


The answers affect how the interface should be designed. Personally, it seems to me that the reference counting is on a very low level (the caller has to take care of it himself), meaning it would be easy to make mistakes. Make your interface easy to use correctly, and hard to use incorrectly. Reference counting might not even be necessary here, depending on what the array is meant to be used for.