]> git.donarmstrong.com Git - biopieces.git/commitdiff
updated upload_to_ucsc wiki and added a secure free to c code
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Mon, 21 Jul 2008 23:42:56 +0000 (23:42 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Mon, 21 Jul 2008 23:42:56 +0000 (23:42 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@186 74ccb610-7750-0410-82ae-013aeee3265d

code_c/Maasha/src/inc/common.h
code_c/Maasha/src/lib/common.c

index fcc01bf2b0f557530505928f810f03074c0672e0..41096bcbd73e66aa58de4b580f9159770a904caa 100644 (file)
@@ -55,7 +55,7 @@ struct list_int
 
 
 /* Print error message to stderr and exit. */
-void  die( char *error_msg );
+void die( char *error_msg );
 
 /* Print warning message to stderr. */
 void warn( char *warn_msg );
@@ -65,23 +65,25 @@ void warn( char *warn_msg );
 
 
 /* Get a pointer with a given size of allocated memory. */
-void         *mem_get( size_t size );
+void *mem_get( size_t size );
 
 /* Get a pointer with a given size of allocated and zero'ed memory. */
-void    *mem_get_zero( size_t size );
+void *mem_get_zero( size_t size );
 
 /* Resize allocated memory for a given pointer. */
-void      *mem_resize( void* pt, size_t size );
+void *mem_resize( void* pt, size_t size );
 
 /* Resize allocated memory for a given pointer with extra memory zero'ed. */    
 void *mem_resize_zero( void* pt, size_t old_size, size_t new_size );
 
 /* Clone a structure in memory and return a pointer to the clone. */
-void       *mem_clone( void *old_pt, size_t size );
+void *mem_clone( void *old_pt, size_t size );
 
 /* Free memory from a given pointer. */
-void         mem_free( void *pt );
+void  mem_free( void *pt );
 
+/* Zero and then free memory from a given pointer. */
+void  mem_free( void *pt );
 
 /* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ARRAYS <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
 
@@ -94,13 +96,13 @@ bool binary_search_array( int *array, int array_size, int val );
 
 
 /* Remove the last char from a string. */
-void    chop( char *string );
+void  chop( char *string );
 
 /* Remove the last char from a string if the char is a newline (safer than chop). */
-void   chomp( char *string );
+void  chomp( char *string );
 
 /* Split a given line and a delimiter return the split result as a list. */
-void   split( char *string, char delimit, struct list **fields );
+void  split( char *string, char delimit, struct list **fields );
     
 /* Mockup version of Perl substr. */
 char *substr( char *string, int offset, int len );
index 8203a2c971d48724f854e549b10423c307f6283b..c84a02a876243493507110c3238b6cc4b9b80dc0 100644 (file)
@@ -135,6 +135,22 @@ void mem_free( void *pt )
 }
 
 
+void mem_free_zero( void *pt )
+{
+    /* Martin A. Hansen, July 2008 */
+
+    /* Zero and then free memory from a given pointer. */
+
+    if ( pt != NULL )
+    {
+        ZERO( pt );
+        free( pt );
+
+        pt = NULL;
+    }
+}
+
+
 /* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ARRAYS <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/