"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "Basic/Core/pdlmagic.c" between
PDL-2.076.tar.gz and PDL-2.077.tar.gz

About: PDL (Perl Data Language) aims to turn perl into an efficient numerical language for scientific computing (similar to IDL and MatLab).

pdlmagic.c  (PDL-2.076):pdlmagic.c  (PDL-2.077)
skipping to change at line 447 skipping to change at line 447
void pdl_pthread_realloc_vsnprintf(char **p, size_t *len, size_t extralen, const char *pat, va_list *args, char add_newline) { void pdl_pthread_realloc_vsnprintf(char **p, size_t *len, size_t extralen, const char *pat, va_list *args, char add_newline) {
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_lock( &mutex ); pthread_mutex_lock( &mutex );
/* (For windows, we first #undef realloc /* (For windows, we first #undef realloc
so that the system realloc function is used instead of the PerlMem_realloc so that the system realloc function is used instead of the PerlMem_realloc
macro. This currently works fine, though could conceivably require some macro. This currently works fine, though could conceivably require some
tweaking in the future if it's found to cause any problem.) */ tweaking in the future if it's found to cause any problem.) */
#ifdef WIN32 #ifdef WIN32
#undef realloc #undef realloc
#endif #endif
/* FIXME: Common realloc mistake: 'msgs' nulled but not freed upon failure */
if (add_newline) extralen += 1; if (add_newline) extralen += 1;
*p = realloc(*p, *len + extralen + 1); /* +1 for '\0' at end */ extralen += 1; /* +1 for '\0' at end */
vsnprintf(*p + *len, extralen + 1, pat, *args); *p = realloc(*p, *len + extralen);
/* update the length-so-far. This does NOT include the trailing '\0' */ vsnprintf(*p + *len, extralen, pat, *args);
*len += extralen; *len += extralen; /* update the length-so-far, includes '\0' */
if (add_newline)(*p)[*len] = '\n'; if (add_newline) (*p)[*len-2] = '\n';
(*p)[*len+1] = '\0'; (*p)[*len-1] = '\0';
pthread_mutex_unlock( &mutex ); pthread_mutex_unlock( &mutex );
} }
void pdl_pthread_free(void *p) { void pdl_pthread_free(void *p) {
#ifdef WIN32 /* same reasons as above */ #ifdef WIN32 /* same reasons as above */
#undef free #undef free
#endif #endif
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_lock( &mutex ); pthread_mutex_lock( &mutex );
free(p); free(p);
 End of changes. 2 change blocks. 
7 lines changed or deleted 6 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)