diff options
author | Diego 'Flameeyes' Pettenò <flameeyes@gmail.com> | 2006-09-09 19:35:40 +0000 |
---|---|---|
committer | Diego 'Flameeyes' Pettenò <flameeyes@gmail.com> | 2006-09-09 19:35:40 +0000 |
commit | 1c7be91287cdc473e8eaf593c2c5e23a92368a19 (patch) | |
tree | e816e96a538df9b2086e6ae9b37dad6df0039592 /src/xine-engine/scratch.c | |
parent | ab481384d1d547c4f8794489f95b3ddf28c8e17a (diff) | |
download | xine-lib-1c7be91287cdc473e8eaf593c2c5e23a92368a19.tar.gz xine-lib-1c7be91287cdc473e8eaf593c2c5e23a92368a19.tar.bz2 |
Dynamically create the log_buffers entries and the lines buffers for the logs, so that it does not waste 450KiB immediately at startup.
CVS patchset: 8212
CVS date: 2006/09/09 19:35:40
Diffstat (limited to 'src/xine-engine/scratch.c')
-rw-r--r-- | src/xine-engine/scratch.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/xine-engine/scratch.c b/src/xine-engine/scratch.c index 2dfd80b54..b8f72ee93 100644 --- a/src/xine-engine/scratch.c +++ b/src/xine-engine/scratch.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: scratch.c,v 1.18 2006/07/17 17:59:56 dsalt Exp $ + * $Id: scratch.c,v 1.19 2006/09/09 19:35:40 dgp85 Exp $ * * top-level xine functions * @@ -50,6 +50,9 @@ static void __attribute__((__format__(__printf__, 2, 0))) time (&t); localtime_r (&t, &tm); + if ( ! this->lines[this->cur] ) + this->lines[this->cur] = xine_xmalloc(SCRATCH_LINE_LEN_MAX+1); + strftime (this->lines[this->cur], SCRATCH_LINE_LEN_MAX, "%X: ", &tm); l = strlen (this->lines[this->cur]); vsnprintf (this->lines[this->cur] + l, SCRATCH_LINE_LEN_MAX - l, format, argp); @@ -79,10 +82,11 @@ static void scratch_dispose (scratch_buffer_t *this) { int i; mem = (char *) this->lines[0]; - free(mem); - for(i = 0; i < this->num_lines; i++ ) + for(i = 0; i < this->num_lines; i++ ) { + free(this->lines[i]); this->lines[i] = NULL; + } free (this->lines); free (this->ordered); @@ -99,10 +103,8 @@ scratch_buffer_t *_x_new_scratch_buffer (int num_lines) { this->lines = xine_xmalloc (sizeof (char *) * (num_lines + 1)); this->ordered = xine_xmalloc (sizeof (char *) * (num_lines + 1)); - mem = (char *) xine_xmalloc((sizeof(char) * SCRATCH_LINE_LEN_MAX) * num_lines); - for (i = 0; i < num_lines; i++) - this->lines[i] = (char *) (mem + (i * SCRATCH_LINE_LEN_MAX)); + this->lines[i] = NULL; this->ordered[i] = NULL; this->lines[i] = NULL; |