/[ascend]/trunk/base/generic/utilities/ascMalloc.h
ViewVC logotype

Diff of /trunk/base/generic/utilities/ascMalloc.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 668 by johnpye, Mon May 29 06:32:42 2006 UTC revision 669 by johnpye, Wed Jun 21 07:00:45 2006 UTC
# Line 100  Line 100 
100   *  @return A new copy of str as a char *, or NULL if an error occurs.   *  @return A new copy of str as a char *, or NULL if an error occurs.
101   */   */
102    
103    /**
104        Shorthand for creating pointers to newly allocated data of a given type
105    */
106    #define ASC_NEW(TYPE) (TYPE *)ascmalloc(sizeof(TYPE))
107    
108    #define ASC_NEW_CLEAR(TYPE) (TYPE *)asccalloc(1,sizeof(TYPE))
109    
110    /**
111        Shorthand for creating pointer to an array of newly allocated data of a
112        given type. 'ascmalloc' is used for the allocation.
113    */
114    #define ASC_NEW_ARRAY(TYPE,COUNT) (TYPE *)ascmalloc(sizeof(TYPE)*(COUNT))
115    
116    /**
117        Shorthand for creating a pointer to allocated data, using asccalloc (to zero
118        the allocated space).
119    */
120    #define ASC_NEW_ARRAY_CLEAR(TYPE,COUNT) (TYPE *)asccalloc(COUNT,sizeof(TYPE))
121    
122    /**
123        Shorthand for creating a pointer to an array of allocated data. If the
124        specified length is zero, no space is allocated, and a NULL is returned
125        instead.
126    */
127    #define ASC_NEW_ARRAY_OR_NULL(TYPE,COUNT) \
128        ((COUNT)>0 ? ASC_NEW_ARRAY(TYPE,COUNT) : NULL)
129    
130    #define ASC_NEW_ARRAY_OR_NULL_CLEAR(TYPE,COUNT) \
131        ((COUNT)>0 ? ASC_NEW_ARRAY_CLEAR(TYPE,COUNT) : NULL)
132    
133    /* regular expressions for fixing up mallocs (in regexxer)
134        \(([^\*\)]+) ?\*\)\s*ascmalloc\(sizeof\(\1\)\s*\*\s*([a-zA-Z][a-zA-Z_0-9]*)\)
135    \(([^\*\)]+) ?\*\)\s*asccalloc\(([a-zA-Z][a-zA-Z_0-9]*)\s*,\s*sizeof\(\1\)\s*\)
136    */
137    
138    #define ASC_FREE(PTR) ascfree(PTR)
139    
140  ASC_DLLSPEC(char *) ascstrdupf(CONST char *str);  ASC_DLLSPEC(char *) ascstrdupf(CONST char *str);
141  /**<  /**<
142   *  Implementation function for ascstrdup() if MALLOC_DEBUG   *  Implementation function for ascstrdup() if MALLOC_DEBUG

Legend:
Removed from v.668  
changed lines
  Added in v.669

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22