StudlyCaps wrote:
Abandon and discard may be confusing, because both imply no longer using something, but not actually destroying it.
Thanks for your replies. @iansjack @max
I think I should describe this function in more detail:
This is the 'line' structure:
Code:
struct viline{
char *buf;
int len;
int size;
int flags;
};
The function 'viline_discard(struct viline *line)' works like this:
check 'viline->flags' to see whether this line is sharing the string buffer(namely 'viline->buf') with some other(s).
if yes, decrement the reference count. if no or the reference count turns zero, call free() to release the buffer.
This function won't touch any field of the 'viline' structure, but after it returns, the 'viline' turns into a meaningless structure never holding string buffer any more, and this structure can be recycled.
So I think viline_destroy() is not vivid.