LibFile complains about lack of memory

Timothy Baldwin T.E.Baldwin99 at members.leeds.ac.uk
Sun Aug 11 13:14:30 PDT 2002


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thursday 08 Aug 2002 10:50 pm, Alex Waugh wrote:
> In message <200208080054.26117.T.E.Baldwin99 at members.leeds.ac.uk>
>
>           Timothy Baldwin <T.E.Baldwin99 at members.leeds.ac.uk> wrote:
> > When atempting to create an empty library which already exists LibFile
> > complains about lack of memory, then exits successfully!

[snip]

> It will also give the same error if you try to add a zero length file to
> an library. I suspect it is either misreporting the error, or failing to
> take account of boundary cases correctly. I might have a go at fixing it
> at some point.

A couple more bugs:
The number of used chunks is written incorrectly in the library header.
The symbol table give incorrect chunks for newly inserted objects.

diff -burN gccsdk-old/riscos-aof/libfile/Buffer.cc 
gccsdk2/riscos-aof/libfile/Buffer.cc
- - --- gccsdk-old/riscos-aof/libfile/Buffer.cc	Sat Jul 27 17:26:27 2002
+++ gccsdk2/riscos-aof/libfile/Buffer.cc	Sun Aug 11 14:50:37 2002
@@ -18,7 +18,7 @@
 {
  m_size=1000;
  m_data=(unsigned char *) malloc(m_size*sizeof(unsigned char));
- - - if(!m_data)
+ if(!m_data && m_size)
  	THROW_SPEC_ERR(BError::NewFailed);
  m_length=0;
 }
@@ -28,7 +28,7 @@
  m_size=a_buffer.m_size;
  m_length=a_buffer.m_length;
  m_data=(unsigned char *) malloc(m_size*sizeof(unsigned char));
- - - if(!m_data)
+ if(!m_data && m_size)
  	THROW_SPEC_ERR(BError::NewFailed);
  memcpy(m_data,a_buffer.m_data,m_length);
 }
@@ -38,7 +38,7 @@
  m_size=a_buffer->m_size;
  m_length=a_buffer->m_length;
  m_data=(unsigned char *) malloc(m_size*sizeof(unsigned char));
- - - if(!m_data)
+ if(!m_data && m_size)
  	THROW_SPEC_ERR(BError::NewFailed);
  memcpy(m_data,a_buffer->m_data,m_length);
 }
@@ -55,7 +55,7 @@
  	free(m_data);
  m_size=1000;
  m_data=(unsigned char *) malloc(m_size*sizeof(unsigned char));
- - - if(!m_data)
+ if(!m_data && m_size)
  	THROW_SPEC_ERR(BError::NewFailed);
  m_length=0;
 }
@@ -65,7 +65,7 @@
  m_size=a_buffer->m_size;
  m_length=a_buffer->m_length;
  m_data=(unsigned char *) realloc(m_data, m_size*sizeof(unsigned char));
- - - if(!m_data)
+ if(!m_data && m_size)
  	THROW_SPEC_ERR(BError::NewFailed);
  memcpy(m_data,a_buffer->m_data,m_length);
 }
@@ -75,7 +75,7 @@
  m_size = a_len;
  m_length = a_len;
  m_data = (unsigned char *) realloc(m_data, m_size*sizeof(unsigned char));
- - - if(!m_data)
+ if(!m_data && m_size)
  	THROW_SPEC_ERR(BError::NewFailed);
  memcpy(m_data, &((a_buffer->m_data)[a_start]), m_length);
 }
@@ -88,7 +88,7 @@
  m_size=a_buffer.m_size;
  m_length=a_buffer.m_length;
  m_data=(unsigned char *) malloc(m_size*sizeof(unsigned char));
- - - if(!m_data)
+ if(!m_data && m_size)
  	THROW_SPEC_ERR(BError::NewFailed);
  memcpy(m_data,a_buffer.m_data,m_length);
  return *this;
@@ -98,7 +98,7 @@
 {
  m_size+=a_bytes;
  m_data=(unsigned char *) realloc(m_data,m_size*sizeof(unsigned char));
- - - if(!m_data)
+ if(!m_data && m_size)
  	THROW_SPEC_ERR(BError::NewFailed);
 }
 
diff -burN gccsdk-old/riscos-aof/libfile/Librarian.cc 
gccsdk2/riscos-aof/libfile/Librarian.cc
- - --- gccsdk-old/riscos-aof/libfile/Librarian.cc	Sat Jul 27 17:26:27 2002
+++ gccsdk2/riscos-aof/libfile/Librarian.cc	Sun Aug 11 19:49:32 2002
@@ -114,8 +114,8 @@
 		  }

   		library->addMembers(argList);
- - - 		library->updateOflSymt();
  		library->updateOflTime();
+ 		library->updateOflSymt();
   		library->save();
   		break;
 
@@ -143,8 +143,8 @@
   			library->extractMembers(argList, destDir);
 
   		library->deleteMembers(argList);
- - - 		library->updateOflSymt();
  		library->updateOflTime();
+ 		library->updateOflSymt();
   		library->save();
   		break;
 
diff -burN gccsdk-old/riscos-aof/libfile/Library.cc 
gccsdk2/riscos-aof/libfile/Library.cc
- - --- gccsdk-old/riscos-aof/libfile/Library.cc	Sun Jul 28 11:18:13 2002
+++ gccsdk2/riscos-aof/libfile/Library.cc	Sun Aug 11 14:00:36 2002
@@ -50,7 +50,7 @@
  m_data.putInt(members);
 
  // Number of used chunks
- - - m_data.putInt(members - 1);
+ m_data.putInt(members);

  // Get current timestamp
  m_time->set();


- - -- 
Timothy Baldwin
Member WYLUG, SWP, ANL, Leeds SA, Leeds Anti-war coalition
Stop the EU Copyright Directive!
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE9VsWnRyxeA0fSpFERAl2yAJ0cf3+ya5q+aS4Wf09o/vy26cSiLwCgwsuG
+WcorCSfNBTcuuwBPEY2zPc=
=eGhB
-----END PGP SIGNATURE-----



More information about the gcc mailing list