Changeset 139
- Timestamp:
- Mar 4, 2004, 4:57:24 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/doc/draft/utils.tex (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/draft/utils.tex
r135 r139 359 359 The API for this field is: 360 360 \begin{verbatim} 361 int psMemGetRefC ntr(void *vptr); // return refcntr362 void *psMemIncrRefC ntr(void *vptr); // increment refcntr and return vptr363 void *psMemDecrRefC ntr(void *vptr); // decrement refcntr and return vptr364 \end{verbatim} 365 366 The functions \code{psMemIncrRefC ntr} and \code{psMemDecrRefCntr} shall361 int psMemGetRefCounter(void *vptr); // return refcounter 362 void *psMemIncrRefCounter(void *vptr); // increment refcounter and return vptr 363 void *psMemDecrRefCounter(void *vptr); // decrement refcounter and return vptr 364 \end{verbatim} 365 366 The functions \code{psMemIncrRefCounter} and \code{psMemDecrRefCounter} shall 367 367 return \code{NULL} if passed a \code{NULL} pointer. 368 368 … … 389 389 if (simp == NULL) { return; } 390 390 391 if (psMemGetRefC ntr(simp) > 1) {392 (void)psMemDecrRefC ntr(simp);391 if (psMemGetRefCounter(simp) > 1) { 392 (void)psMemDecrRefCounter(simp); 393 393 return; 394 394 } … … 401 401 \end{table} 402 402 403 The \code{psMemBlock.refc ntr} is clearly useful for detecting403 The \code{psMemBlock.refcounter} is clearly useful for detecting 404 404 attempts to free memory that is already free. A more complex 405 405 application is for allowing pointers to complex data-objects (e.g. … … 407 407 (see table \ref{tabReferenceCounting}). 408 408 409 Because of the use of the \code{refc ntr} field, we can safely put items of409 Because of the use of the \code{refcounter} field, we can safely put items of 410 410 this type onto many lists: 411 411 \goodbreak 412 412 \begin{verbatim} 413 413 simp = psSimpleNew("RHL", 0); 414 psDlistAppend(list1, psMemIncrRefC ntr(simp));415 psDlistAppend(list2, psMemIncrRefC ntr(simp));414 psDlistAppend(list1, psMemIncrRefCounter(simp)); 415 psDlistAppend(list2, psMemIncrRefCounter(simp)); 416 416 psSimpleDel(simp); 417 417 \end{verbatim} … … 695 695 696 696 All data items placed onto lists (e.g. with \code{psDlistAdd}) 697 shall have their reference counters (section \ref{secMemRefc ntr}) incremented.697 shall have their reference counters (section \ref{secMemRefcounter}) incremented. 698 698 When elements 699 699 are removed from a list with \code{psDlistRemove}, they shall … … 704 704 If \code{psDlistDel}'s argument \code{elemDel} is NULL, the 705 705 list should be deleted, but not the elements on it (although their 706 \code{refc ntr}'s should be decremented).706 \code{refcounter}'s should be decremented). 707 707 708 708 The \code{psDlistGet} routine may be used to provide an iterator. The … … 801 801 source file for a given type). 802 802 803 The objects pointed to by these types have had their \code{refC ntr}s804 incremented (see \ref{secMemRefc ntr}); to remove an element from the array you803 The objects pointed to by these types have had their \code{refCounter}s 804 incremented (see \ref{secMemRefcounter}); to remove an element from the array you 805 805 need to say something like: 806 806 \begin{verbatim} 807 807 psTypePtrArray *pt = psTypePtrArrayNew(10, 10); 808 psType *xy = psMemDecrRefC ntr(pt->arr[0]);808 psType *xy = psMemDecrRefCounter(pt->arr[0]); 809 809 pt->arr[0] = NULL; 810 810 \end{verbatim} … … 832 832 had their reference counters incremented 833 833 when they were inserted onto the array.\footnote{% 834 \eg{} \code{va->arr[i] = psMemIncrRefC ntr(ptr);}}834 \eg{} \code{va->arr[i] = psMemIncrRefCounter(ptr);}} 835 835 836 836 If \code{psVoidPtrArrayDel}'s argument \code{elemDel} is NULL, the 837 837 list should be deleted, but not the elements on it (although their 838 \code{refc ntr}'s should be decremented).838 \code{refcounter}'s should be decremented). 839 839 840 840 \subsection{Examples of Array Types} … … 885 885 psXYArrayDel(t); 886 886 887 psXY *xy = psMemDecrRefC ntr(pt->arr[0]);887 psXY *xy = psMemDecrRefCounter(pt->arr[0]); 888 888 pt->arr[0] = NULL; 889 889 psXYDel(xy);
Note:
See TracChangeset
for help on using the changeset viewer.
