- Timestamp:
- Mar 9, 2006 1:10:14 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/mesh/grid1d.cc
r297 r300 93 93 int nbytes = numBytes(); 94 94 95 // total length = tagEncode + tagCompress + num + array data 96 if ( (buf = (char*) malloc(nbytes)) == NULL) { 97 RpAppendErr("RpGrid1d::serialize: malloc failed"); 95 if ( (buf = new char[nbytes]) == NULL) { 96 RpAppendErr("RpGrid1d::serialize: new char[] failed"); 98 97 RpPrintErr(); 99 98 return buf; … … 122 121 char * ptr = buf; 123 122 124 writeHeader(ptr, RpGrid1d_current_version, nbytes); 123 // write object header (version and typename) 124 writeRpHeader(ptr, RpGrid1d_current_version, nbytes); 125 125 ptr += HEADER_SIZE + sizeof(int); 126 126 127 writeObjectName(ptr, m_name); 127 // write object name and its length 128 writeString(ptr, m_name); 128 129 ptr += m_name.size() + sizeof(int); 129 130 130 // copy int (number of points) 131 131 // write number of points and array data 132 132 writeArrayDouble(ptr, m_data, m_data.size()); 133 133 … … 148 148 int nbytes; 149 149 150 read Header(ptr, header, nbytes);150 readRpHeader(ptr, header, nbytes); 151 151 ptr += HEADER_SIZE + sizeof(int); 152 152 … … 169 169 // parse object name and store name in m_name 170 170 171 read ObjectName(ptr, m_name);171 readString(ptr, m_name); 172 172 ptr += sizeof(int) + m_name.size(); 173 173 174 174 int npts; 175 readArrayDouble(ptr, &m_data, npts);175 readArrayDouble(ptr, m_data, npts); 176 176 177 177 return RP_SUCCESS; … … 196 196 197 197 DataValType* xy; 198 if ( (xy = new DataValType (npts)) == NULL) {198 if ( (xy = new DataValType[npts]) == NULL) { 199 199 RpAppendErr("RpGrid1d::data: mem alloc failed"); 200 200 RpPrintErr(); … … 282 282 + m_data.size() * sizeof(DataValType); 283 283 284 #ifdef DEBUG 285 printf("RpGrid1d::numBytes returns %d\n", nbytes); 286 #endif 284 287 return nbytes; 285 288 }
Note: See TracChangeset
for help on using the changeset viewer.