SAGA API  v9.6
api_memory.cpp
Go to the documentation of this file.
1 
3 // //
4 // SAGA //
5 // //
6 // System for Automated Geoscientific Analyses //
7 // //
8 // Application Programming Interface //
9 // //
10 // Library: SAGA_API //
11 // //
12 //-------------------------------------------------------//
13 // //
14 // api_memory.cpp //
15 // //
16 // Copyright (C) 2005 by Olaf Conrad //
17 // //
18 //-------------------------------------------------------//
19 // //
20 // This file is part of 'SAGA - System for Automated //
21 // Geoscientific Analyses'. //
22 // //
23 // This library is free software; you can redistribute //
24 // it and/or modify it under the terms of the GNU Lesser //
25 // General Public License as published by the Free //
26 // Software Foundation, either version 2.1 of the //
27 // License, or (at your option) any later version. //
28 // //
29 // This library is distributed in the hope that it will //
30 // be useful, but WITHOUT ANY WARRANTY; without even the //
31 // implied warranty of MERCHANTABILITY or FITNESS FOR A //
32 // PARTICULAR PURPOSE. See the GNU Lesser General Public //
33 // License for more details. //
34 // //
35 // You should have received a copy of the GNU Lesser //
36 // General Public License along with this program; if //
37 // not, see <http://www.gnu.org/licenses/>. //
38 // //
39 //-------------------------------------------------------//
40 // //
41 // contact: Olaf Conrad //
42 // Institute of Geography //
43 // University of Goettingen //
44 // Goldschmidtstr. 5 //
45 // 37077 Goettingen //
46 // Germany //
47 // //
48 // e-mail: oconrad@saga-gis.org //
49 // //
51 
52 //---------------------------------------------------------
53 #include "api_core.h"
54 
55 
57 // //
58 // //
59 // //
61 
62 #ifndef _WINDOWS_
63 
64 //---------------------------------------------------------
65 void * SG_Malloc(size_t size)
66 {
67  return( malloc(size) );
68 }
69 
70 //---------------------------------------------------------
71 void * SG_Calloc(size_t num, size_t size)
72 {
73  return( calloc(num, size) );
74 }
75 
76 //---------------------------------------------------------
77 void * SG_Realloc(void *memblock, size_t new_size)
78 {
79  return( realloc(memblock, new_size) );
80 }
81 
82 //---------------------------------------------------------
83 void SG_Free(void *memblock)
84 {
85  if( memblock )
86  {
87  free(memblock);
88  }
89 }
90 
91 
93 // //
94 // //
95 // //
97 
98 //---------------------------------------------------------
99 // Due to a bad 'feature' in the realloc routine of MS's
100 // MSVCRT (C-Runtime-Library), we recommend to use our own
101 // memory allocation routines...
102 
103 #else // ifndef _WINDOWS_
104 
105 void * SG_Malloc(size_t size)
106 {
107  return( HeapAlloc(GetProcessHeap(), 0, size) );
108 }
109 
110 void * SG_Calloc(size_t num, size_t size)
111 {
112  return( HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, num * size) );
113 }
114 
115 void * SG_Realloc(void *memblock, size_t new_size)
116 {
117  if( new_size > 0 )
118  {
119  if( memblock )
120  {
121  return( HeapReAlloc(GetProcessHeap(), 0, memblock, new_size) );
122  }
123  else
124  {
125  return( HeapAlloc(GetProcessHeap(), 0, new_size) );
126  }
127  }
128  else
129  {
130  SG_Free(memblock);
131 
132  return( NULL );
133  }
134 }
135 
136 void SG_Free(void *memblock)
137 {
138  if( memblock )
139  {
140  HeapFree(GetProcessHeap(), 0, memblock);
141  }
142 }
143 
144 #endif // ifndef _WINDOWS_
145 
146 
148 // //
149 // //
150 // //
152 
153 //---------------------------------------------------------
154 void SG_Swap_Bytes(void *Buffer, int nBytes)
155 {
156  char Byte, *pA, *pB;
157 
158  pA = (char *)Buffer;
159  pB = pA + nBytes - 1;
160 
161  while( pA < pB )
162  {
163  Byte = *pA;
164  *(pA++) = *pB;
165  *(pB--) = Byte;
166  }
167 }
168 
169 
171 // //
172 // //
173 // //
175 
176 //---------------------------------------------------------
177 int SG_Mem_Get_Int(const char *Buffer, bool bSwapBytes)
178 {
179  int Value = *(int *)Buffer;
180 
181  if( bSwapBytes )
182  {
183  SG_Swap_Bytes(&Value, sizeof(Value));
184  }
185 
186  return( Value );
187 }
188 
189 void SG_Mem_Set_Int(char *Buffer, int Value, bool bSwapBytes)
190 {
191  if( bSwapBytes )
192  {
193  SG_Swap_Bytes(&Value, sizeof(Value));
194  }
195 
196  *((int *)Buffer) = Value;
197 }
198 
199 //---------------------------------------------------------
200 double SG_Mem_Get_Double(const char *Buffer, bool bSwapBytes)
201 {
202  double Value = *(double *)Buffer;
203 
204  if( bSwapBytes )
205  {
206  SG_Swap_Bytes(&Value, sizeof(Value));
207  }
208 
209  return( Value );
210 }
211 
212 void SG_Mem_Set_Double(char *Buffer, double Value, bool bSwapBytes)
213 {
214  if( bSwapBytes )
215  {
216  SG_Swap_Bytes(&Value, sizeof(Value));
217  }
218 
219  *(double *)Buffer = Value;
220 }
221 
222 
224 // //
225 // //
226 // //
228 
229 //---------------------------------------------------------
231 {
232  m_nBuffer = 0;
233  m_nValues = 0;
234  m_Values = NULL;
235 
236  m_Value_Size = sizeof(char);
237  m_Growth = TSG_Array_Growth::SG_ARRAY_GROWTH_0;
238 }
239 
240 //---------------------------------------------------------
242 {
243  m_nBuffer = 0;
244  m_nValues = 0;
245  m_Values = NULL;
246 
247  Create(Array);
248 }
249 
250 void * CSG_Array::Create(const CSG_Array &Array)
251 {
252  Destroy();
253 
254  m_Value_Size = Array.m_Value_Size;
255  m_Growth = Array.m_Growth;
256 
257  if( Array.m_nValues > 0 && Get_Array(Array.m_nValues) )
258  {
259  memcpy(m_Values, Array.m_Values, Array.m_nValues * Array.m_Value_Size);
260  }
261 
262  return( Get_Array() );
263 }
264 
265 //---------------------------------------------------------
266 CSG_Array::CSG_Array(size_t Value_Size, sLong nValues, TSG_Array_Growth Growth)
267 {
268  m_nBuffer = 0;
269  m_nValues = 0;
270  m_Values = NULL;
271 
272  Create(Value_Size, nValues, Growth);
273 }
274 
275 void * CSG_Array::Create(size_t Value_Size, sLong nValues, TSG_Array_Growth Growth)
276 {
277  Destroy();
278 
279  m_Value_Size = Value_Size;
280  m_Growth = Growth;
281 
282  return( Get_Array(nValues) );
283 }
284 
285 //---------------------------------------------------------
287 {
288  Destroy();
289 }
290 
292 {
293  m_nBuffer = 0;
294  m_nValues = 0;
295 
296  SG_FREE_SAFE(m_Values);
297 
298  return( true );
299 }
300 
301 //---------------------------------------------------------
303 {
304  m_Growth = Growth;
305 
306  return( true );
307 }
308 
309 //---------------------------------------------------------
310 bool CSG_Array::Set_Array(sLong nValues, bool bShrink)
311 {
312  if( nValues >= m_nValues && nValues <= m_nBuffer )
313  {
314  m_nValues = nValues;
315 
316  return( true );
317  }
318 
319  if( nValues < m_nValues && !bShrink )
320  {
321  m_nValues = nValues;
322 
323  return( true );
324  }
325 
326  if( nValues == 0 )
327  {
328  Destroy();
329 
330  return( true );
331  }
332 
333  //-----------------------------------------------------
334  sLong nBuffer;
335 
336  switch( m_Growth )
337  {
338  case TSG_Array_Growth::SG_ARRAY_GROWTH_0: default:
339  nBuffer = nValues;
340  break;
341 
342  case TSG_Array_Growth::SG_ARRAY_GROWTH_1:
343  nBuffer = nValues < 10 ? nValues
344  : nValues < 100 ? (1 + nValues / 10) * 10
345  : nValues < 1000 ? (1 + nValues / 100) * 100
346  : nValues < 10000 ? (1 + nValues / 1000) * 1000
347  : (1 + nValues / 10000) * 10000;
348  break;
349 
350  case TSG_Array_Growth::SG_ARRAY_GROWTH_2:
351  nBuffer = nValues < 100 ? nValues
352  : nValues < 1000 ? (1 + nValues / 10) * 10
353  : nValues < 10000 ? (1 + nValues / 100) * 100
354  : nValues < 100000 ? (1 + nValues / 1000) * 1000
355  : (1 + nValues / 10000) * 10000;
356  break;
357 
358  case TSG_Array_Growth::SG_ARRAY_GROWTH_3:
359  nBuffer = nValues < 1000 ? (1 + nValues / 1000) * 1000
360  : nValues < 10000 ? (1 + nValues / 10000) * 10000
361  : nValues < 100000 ? (1 + nValues / 100000) * 100000
362  : (1 + nValues / 1000000) * 1000000;
363  break;
364 
365  case TSG_Array_Growth::SG_ARRAY_GROWTH_FIX_8 : nBuffer = (1 + nValues / 8) * 8; break;
366  case TSG_Array_Growth::SG_ARRAY_GROWTH_FIX_16 : nBuffer = (1 + nValues / 16) * 16; break;
367  case TSG_Array_Growth::SG_ARRAY_GROWTH_FIX_32 : nBuffer = (1 + nValues / 32) * 32; break;
368  case TSG_Array_Growth::SG_ARRAY_GROWTH_FIX_64 : nBuffer = (1 + nValues / 64) * 64; break;
369  case TSG_Array_Growth::SG_ARRAY_GROWTH_FIX_128 : nBuffer = (1 + nValues / 128) * 128; break;
370  case TSG_Array_Growth::SG_ARRAY_GROWTH_FIX_256 : nBuffer = (1 + nValues / 256) * 256; break;
371  case TSG_Array_Growth::SG_ARRAY_GROWTH_FIX_512 : nBuffer = (1 + nValues / 512) * 512; break;
372  case TSG_Array_Growth::SG_ARRAY_GROWTH_FIX_1024: nBuffer = (1 + nValues / 1024) * 1024; break;
373  }
374 
375  //-----------------------------------------------------
376  if( nBuffer == m_nBuffer )
377  {
378  m_nValues = nValues;
379 
380  return( true );
381  }
382 
383  //-----------------------------------------------------
384  void *Values = SG_Realloc(m_Values, nBuffer * m_Value_Size);
385 
386  if( Values )
387  {
388  m_nBuffer = nBuffer;
389  m_nValues = nValues;
390  m_Values = Values;
391 
392  return( true );
393  }
394 
395  return( false );
396 }
397 
398 //---------------------------------------------------------
399 bool CSG_Array::Set_Array(sLong nValues, void **pArray, bool bShrink)
400 {
401  if( Set_Array(nValues, bShrink) )
402  {
403  *pArray = m_Values;
404 
405  return( true );
406  }
407 
408  *pArray = m_Values;
409 
410  return( false );
411 }
412 
413 //---------------------------------------------------------
415 {
416  return( Set_Array(m_nValues + nValues) );
417 }
418 
419 bool CSG_Array::Inc_Array (void **pArray)
420 {
421  return( Set_Array(m_nValues + 1, pArray) );
422 }
423 
424 //---------------------------------------------------------
425 bool CSG_Array::Dec_Array (bool bShrink)
426 {
427  return( m_nValues > 0 ? Set_Array(m_nValues - 1, bShrink) : false );
428 }
429 
430 bool CSG_Array::Dec_Array (void **pArray, bool bShrink)
431 {
432  return( m_nValues > 0 ? Set_Array(m_nValues - 1, pArray, bShrink) : false );
433 }
434 
435 //---------------------------------------------------------
436 bool CSG_Array::Del_Entry(sLong Index, bool bShrink)
437 {
438  if( Index >= 0 && Index < m_nValues )
439  {
440  if( Index < m_nValues - 1 )
441  {
442  char *ip = (char *)m_Values + Index * m_Value_Size; char *jp = ip + m_Value_Size;
443 
444  for(sLong i=Index, j=Index+1; j<m_nValues; i++, j++, ip+=m_Value_Size, jp+=m_Value_Size)
445  {
446  for(size_t k=0; k<m_Value_Size; k++)
447  {
448  ip[k] = jp[k];
449  }
450  }
451  }
452 
453  Set_Array(m_nValues - 1, bShrink);
454 
455  return( true );
456  }
457 
458  return( false );
459 }
460 
461 
463 // //
464 // //
465 // //
467 
468 //---------------------------------------------------------
470 {
471  m_Array.Create(Array.m_Array);
472 
473  return( (void **)m_Array.Get_Array() );
474 }
475 
476 //---------------------------------------------------------
478 {
479  m_Array.Create(sizeof(void *), nValues, Growth);
480 
481  return( (void **)m_Array.Get_Array() );
482 }
483 
484 //---------------------------------------------------------
485 bool CSG_Array_Pointer::Add(void *Value)
486 {
487  if( Inc_Array() )
488  {
489  Get_Array()[Get_Size() - 1] = Value;
490 
491  return( true );
492  }
493 
494  return( false );
495 }
496 
497 //---------------------------------------------------------
499 {
500  for(sLong i=0; i<Array.Get_Size(); i++)
501  {
502  if( Add(Array[i]) == false )
503  {
504  return( false );
505  }
506  }
507 
508  return( true );
509 }
510 
511 //---------------------------------------------------------
513 {
514  if( Index < Get_Size() )
515  {
516  for(sLong i=Index+1; i<Get_Size(); i++, Index++)
517  {
518  (*this)[Index] = (*this)[i];
519  }
520 
521  return( Dec_Array() );
522  }
523 
524  return( false );
525 }
526 
527 //---------------------------------------------------------
529 {
530  sLong n = 0;
531 
532  for(sLong i=Get_Size(); i>0; i--)
533  {
534  if( Value == (*this)[i - 1] && Del(i - 1) )
535  {
536  n++;
537  }
538  }
539 
540  return( n );
541 }
542 
543 
545 // //
546 // //
547 // //
549 
550 //---------------------------------------------------------
552 {
553  m_Array.Create(Array.m_Array);
554 
555  return( (int *)m_Array.Get_Array() );
556 }
557 
558 //---------------------------------------------------------
560 {
561  m_Array.Create(sizeof(int), nValues, Growth);
562 
563  return( (int *)m_Array.Get_Array() );
564 }
565 
566 //---------------------------------------------------------
567 bool CSG_Array_Int::Add(int Value)
568 {
569  if( Inc_Array() )
570  {
571  Get_Array()[Get_Size() - 1] = Value;
572 
573  return( true );
574  }
575 
576  return( false );
577 }
578 
579 //---------------------------------------------------------
581 {
582  for(sLong i=0; i<Array.Get_Size(); i++)
583  {
584  if( Add(Array[i]) == false )
585  {
586  return( false );
587  }
588  }
589 
590  return( true );
591 }
592 
593 //---------------------------------------------------------
594 bool CSG_Array_Int::Assign(int Value)
595 {
596  for(sLong i=0; i<Get_Size(); i++)
597  {
598  Get_Array()[i] = Value;
599  }
600 
601  return( true );
602 }
603 
604 
606 // //
607 // //
608 // //
610 
611 //---------------------------------------------------------
613 {
614  m_Array.Create(Array.m_Array);
615 
616  return( (sLong *)m_Array.Get_Array() );
617 }
618 
619 //---------------------------------------------------------
621 {
622  m_Array.Create(sizeof(sLong), nValues, Growth);
623 
624  return( (sLong *)m_Array.Get_Array() );
625 }
626 
627 //---------------------------------------------------------
629 {
630  if( Inc_Array() )
631  {
632  Get_Array()[Get_Size() - 1] = Value;
633 
634  return( true );
635  }
636 
637  return( false );
638 }
639 
640 //---------------------------------------------------------
642 {
643  for(sLong i=0; i<Array.Get_Size(); i++)
644  {
645  if( Add(Array[i]) == false )
646  {
647  return( false );
648  }
649  }
650 
651  return( true );
652 }
653 
654 //---------------------------------------------------------
656 {
657  for(sLong i=0; i<Get_Size(); i++)
658  {
659  Get_Array()[i] = Value;
660  }
661 
662  return( true );
663 }
664 
665 
667 // //
668 // //
669 // //
671 
672 //---------------------------------------------------------
674 {
675  m_Data = NULL;
676  m_Size = 0;
677 }
678 
680 {
681  Destroy();
682 
683  return( true );
684 }
685 
686 //---------------------------------------------------------
688 {
689  m_Data = NULL;
690  m_Size = 0;
691 
692  Create(Buffer);
693 }
694 
695 bool CSG_Buffer::Create(const CSG_Buffer &Buffer)
696 {
697  return( Set_Data(Buffer.m_Data, Buffer.m_Size) );
698 }
699 
700 //---------------------------------------------------------
702 {
703  m_Data = NULL;
704  m_Size = 0;
705 
706  Create(Size);
707 }
708 
709 bool CSG_Buffer::Create(size_t Size)
710 {
711  return( Set_Size(Size) );
712 }
713 
714 //---------------------------------------------------------
716 {
717  Destroy();
718 }
719 
721 {
722  if( m_Data )
723  {
724  SG_Free(m_Data);
725  }
726 
727  m_Data = NULL;
728  m_Size = 0;
729 }
730 
731 //---------------------------------------------------------
732 bool CSG_Buffer::Set_Size(size_t Size, bool bShrink)
733 {
734  if( Size < 1 )
735  {
736  Destroy();
737  }
738  else if( Size > m_Size || (Size < m_Size && bShrink) )
739  {
740  char *Data = (char *)SG_Realloc(m_Data, Size * sizeof(char));
741 
742  if( !Data )
743  {
744  return( false );
745  }
746 
747  m_Data = Data;
748  m_Size = Size;
749  }
750 
751  return( true );
752 }
753 
754 //---------------------------------------------------------
755 bool CSG_Buffer::Set_Data(const char *Data, size_t Size, bool bShrink)
756 {
757  if( !Data || !Size || !Set_Size(Size, bShrink) )
758  {
759  return( false );
760  }
761 
762  memcpy(m_Data, Data, m_Size);
763 
764  return( true );
765 }
766 
767 
769 // //
770 // //
771 // //
773 
774 //---------------------------------------------------------
776 {
777  m_Bytes = NULL;
778  m_nBytes = 0;
779  m_nBuffer = 0;
780  m_Cursor = 0;
781 }
782 
783 //---------------------------------------------------------
785 {
786  return( Destroy() );
787 }
788 
789 //---------------------------------------------------------
791 {
792  m_Bytes = NULL;
793  m_nBytes = 0;
794  m_nBuffer = 0;
795  m_Cursor = 0;
796 
797  Create(Bytes);
798 }
799 
800 bool CSG_Bytes::Create(const CSG_Bytes &Bytes)
801 {
802  return( Assign(Bytes) );
803 }
804 
805 //---------------------------------------------------------
806 CSG_Bytes::CSG_Bytes(const BYTE *Bytes, int nBytes)
807 {
808  m_Bytes = NULL;
809  m_nBytes = 0;
810  m_nBuffer = 0;
811  m_Cursor = 0;
812 
813  Create(Bytes, nBytes);
814 }
815 
816 bool CSG_Bytes::Create(const BYTE *Bytes, int nBytes)
817 {
818  Destroy();
819 
820  return( Add((void *)Bytes, nBytes, false) );
821 }
822 
823 //---------------------------------------------------------
825 {
826  Destroy();
827 }
828 
830 {
831  if( m_Bytes )
832  {
833  SG_Free(m_Bytes);
834  }
835 
836  m_Bytes = NULL;
837  m_nBytes = 0;
838  m_nBuffer = 0;
839  m_Cursor = 0;
840 
841  return( true );
842 }
843 
845 {
846  m_nBytes = 0;
847  m_Cursor = 0;
848 
849  return( true );
850 }
851 
852 
854 // //
856 
857 //---------------------------------------------------------
858 bool CSG_Bytes::_Inc_Array(int nBytes)
859 {
860  if( m_nBuffer < m_nBytes + nBytes )
861  {
862  int nBuffer = m_nBuffer + nBytes + 1024;
863  BYTE *Bytes = (BYTE *)SG_Realloc(m_Bytes, nBuffer * sizeof(BYTE));
864 
865  if( !Bytes )
866  {
867  return( false );
868  }
869 
870  m_Bytes = Bytes;
871  m_nBuffer = nBuffer;
872  }
873 
874  m_nBytes += nBytes;
875 
876  return( true );
877 }
878 
879 
881 // //
883 
884 //---------------------------------------------------------
885 bool CSG_Bytes::Assign(const CSG_Bytes &Bytes)
886 {
887  Destroy();
888 
889  if( _Inc_Array(Bytes.m_nBytes) )
890  {
891  memcpy(m_Bytes, Bytes.m_Bytes, m_nBytes);
892 
893  return( true );
894  }
895 
896  return( false );
897 }
898 
899 
901 // //
903 
904 //---------------------------------------------------------
905 bool CSG_Bytes::Add(const CSG_Bytes &Bytes)
906 {
907  return( Add(Bytes.m_Bytes, Bytes.m_nBytes, false) );
908 }
909 
910 //---------------------------------------------------------
911 bool CSG_Bytes::Add(void *Bytes, int nBytes, bool bSwapBytes)
912 {
913  int Offset = m_nBytes;
914 
915  if( _Inc_Array(nBytes) )
916  {
917  memcpy(m_Bytes + Offset, Bytes, nBytes);
918 
919  if( bSwapBytes )
920  {
921  SG_Swap_Bytes(m_Bytes + Offset, nBytes);
922  }
923 
924  return( true );
925  }
926 
927  return( false );
928 }
929 
930 
932 // //
934 
935 //---------------------------------------------------------
936 BYTE SG_Hex_to_Byte (const SG_Char Hex)
937 {
938  switch( Hex )
939  {
940  case '1': return( 1 );
941  case '2': return( 2 );
942  case '3': return( 3 );
943  case '4': return( 4 );
944  case '5': return( 5 );
945  case '6': return( 6 );
946  case '7': return( 7 );
947  case '8': return( 8 );
948  case '9': return( 9 );
949  case 'a': case 'A': return( 10 );
950  case 'b': case 'B': return( 11 );
951  case 'c': case 'C': return( 12 );
952  case 'd': case 'D': return( 13 );
953  case 'e': case 'E': return( 14 );
954  case 'f': case 'F': return( 15 );
955  }
956 
957  return( 0 );
958 }
959 
960 
962 // //
964 
965 //---------------------------------------------------------
967 {
968  CSG_String HexString;
969 
970  for(int i=0; i<m_nBytes; i++)
971  {
972  HexString += CSG_String::Format(SG_T("%02X"), m_Bytes[i]);
973  }
974 
975  return( HexString );
976 }
977 
978 //---------------------------------------------------------
979 bool CSG_Bytes::fromHexString(const CSG_String &HexString)
980 {
981  Destroy();
982 
983  const SG_Char *s = HexString.c_str();
984 
985  for(size_t i=0; i<HexString.Length(); i+=2, s+=2)
986  {
987  Add((BYTE)(SG_Hex_to_Byte(s[1]) + 16 * SG_Hex_to_Byte(s[0])));
988  }
989 
990  return( true );
991 }
992 
993 
995 // //
996 // //
997 // //
999 
1000 //---------------------------------------------------------
1002 {
1003  m_pBytes = NULL;
1004  m_nBytes = 0;
1005  m_nBuffer = 0;
1006 }
1007 
1008 //---------------------------------------------------------
1010 {
1011  Destroy();
1012 }
1013 
1014 //---------------------------------------------------------
1016 {
1017  if( m_pBytes )
1018  {
1019  for(int i=0; i<m_nBytes; i++)
1020  {
1021  delete(m_pBytes[i]);
1022  }
1023 
1024  SG_Free(m_pBytes);
1025  }
1026 
1027  m_pBytes = NULL;
1028  m_nBytes = 0;
1029  m_nBuffer = 0;
1030 
1031  return( true );
1032 }
1033 
1034 //---------------------------------------------------------
1036 {
1037  if( m_nBytes >= m_nBuffer )
1038  {
1039  CSG_Bytes **pBytes = (CSG_Bytes **)SG_Realloc(m_pBytes, ((uLong)m_nBuffer + 256) * sizeof(CSG_Bytes *));
1040 
1041  if( !pBytes )
1042  {
1043  return( NULL );
1044  }
1045 
1046  m_pBytes = pBytes;
1047  m_nBuffer += 256;
1048  }
1049 
1050  return( m_pBytes[m_nBytes++] = new CSG_Bytes );
1051 }
1052 
1053 
1055 // //
1056 // //
1057 // //
1059 
1060 //---------------------------------------------------------
CSG_Array::Set_Array
bool Set_Array(sLong nValues, bool bShrink=true)
Definition: api_memory.cpp:310
SG_FREE_SAFE
#define SG_FREE_SAFE(PTR)
Definition: api_core.h:205
SG_T
#define SG_T(s)
Definition: api_core.h:537
CSG_Array_sLong::Inc_Array
bool Inc_Array(sLong nValues=1)
Definition: api_core.h:499
SG_Hex_to_Byte
BYTE SG_Hex_to_Byte(const SG_Char Hex)
Definition: api_memory.cpp:936
SG_Malloc
void * SG_Malloc(size_t size)
Definition: api_memory.cpp:65
TSG_Array_Growth
TSG_Array_Growth
Definition: api_core.h:291
SG_Mem_Get_Double
double SG_Mem_Get_Double(const char *Buffer, bool bSwapBytes)
Definition: api_memory.cpp:200
CSG_String::Length
size_t Length(void) const
Definition: api_string.cpp:172
CSG_Bytes::Destroy
bool Destroy(void)
Definition: api_memory.cpp:829
SG_Realloc
void * SG_Realloc(void *memblock, size_t new_size)
Definition: api_memory.cpp:77
CSG_Array_Int::Add
bool Add(int Value)
Definition: api_memory.cpp:567
CSG_Array_Pointer::Get_Size
sLong Get_Size(void) const
Definition: api_core.h:381
CSG_Array_Int::Get_Size
sLong Get_Size(void) const
Definition: api_core.h:436
CSG_Bytes::~CSG_Bytes
virtual ~CSG_Bytes(void)
Definition: api_memory.cpp:824
CSG_Array_Int::Create
int * Create(const CSG_Array_Int &Array)
Definition: api_memory.cpp:551
CSG_Buffer::~CSG_Buffer
virtual ~CSG_Buffer(void)
Definition: api_memory.cpp:715
CSG_Bytes::toHexString
CSG_String toHexString(void) const
Definition: api_memory.cpp:966
SG_Mem_Get_Int
int SG_Mem_Get_Int(const char *Buffer, bool bSwapBytes)
Definition: api_memory.cpp:177
CSG_Array_sLong::Create
sLong * Create(const CSG_Array_sLong &Array)
Definition: api_memory.cpp:612
CSG_Array::Del_Entry
bool Del_Entry(sLong Index, bool bShrink=true)
Definition: api_memory.cpp:436
api_core.h
CSG_Buffer::CSG_Buffer
CSG_Buffer(void)
Definition: api_memory.cpp:673
CSG_Array_Int::Get_Array
int * Get_Array(void) const
Definition: api_core.h:439
CSG_Array_sLong::Get_Size
sLong Get_Size(void) const
Definition: api_core.h:492
CSG_Array_Pointer::Create
void ** Create(const CSG_Array_Pointer &Array)
Definition: api_memory.cpp:469
CSG_Buffer::Set_Size
bool Set_Size(size_t Size, bool bShrink=true)
Definition: api_memory.cpp:732
CSG_Bytes::Add
bool Add(const CSG_Bytes &Bytes)
Definition: api_memory.cpp:905
CSG_Array_Pointer::Inc_Array
bool Inc_Array(sLong nValues=1)
Definition: api_core.h:388
CSG_Bytes_Array::Add
CSG_Bytes * Add(void)
Definition: api_memory.cpp:1035
CSG_Bytes::CSG_Bytes
CSG_Bytes(void)
Definition: api_memory.cpp:775
CSG_Bytes_Array::CSG_Bytes_Array
CSG_Bytes_Array(void)
Definition: api_memory.cpp:1001
CSG_Bytes::Clear
bool Clear(void)
Definition: api_memory.cpp:844
SG_Calloc
void * SG_Calloc(size_t num, size_t size)
Definition: api_memory.cpp:71
CSG_Array_sLong::Assign
bool Assign(sLong Value)
Definition: api_memory.cpp:655
CSG_Buffer
Definition: api_core.h:224
CSG_Array_Pointer::Del
bool Del(sLong Index)
Definition: api_memory.cpp:512
CSG_Buffer::Destroy
void Destroy(void)
Definition: api_memory.cpp:720
CSG_Array::Destroy
bool Destroy(void)
Definition: api_memory.cpp:291
CSG_Array_Int::Assign
bool Assign(int Value)
Definition: api_memory.cpp:594
SG_Free
void SG_Free(void *memblock)
Definition: api_memory.cpp:83
sLong
signed long long sLong
Definition: api_core.h:158
CSG_Array_Pointer::Dec_Array
bool Dec_Array(bool bShrink=true)
Definition: api_core.h:389
SG_Mem_Set_Int
void SG_Mem_Set_Int(char *Buffer, int Value, bool bSwapBytes)
Definition: api_memory.cpp:189
CSG_Array_Int
Definition: api_core.h:423
CSG_Bytes_Array::~CSG_Bytes_Array
virtual ~CSG_Bytes_Array(void)
Definition: api_memory.cpp:1009
CSG_Bytes::fromHexString
bool fromHexString(const CSG_String &HexString)
Definition: api_memory.cpp:979
CSG_Array::Create
void * Create(const CSG_Array &Array)
Definition: api_memory.cpp:250
CSG_Bytes::Assign
bool Assign(const CSG_Bytes &Bytes)
Definition: api_memory.cpp:885
CSG_Array::Get_Array
void * Get_Array(void) const
Definition: api_core.h:336
CSG_Bytes::Create
bool Create(void)
Definition: api_memory.cpp:784
CSG_Array::~CSG_Array
~CSG_Array(void)
Definition: api_memory.cpp:286
CSG_Bytes
Definition: api_core.h:812
CSG_String::Format
static CSG_String Format(const char *Format,...)
Definition: api_string.cpp:270
CSG_Buffer::Set_Data
bool Set_Data(const char *Data, size_t Size, bool bShrink=true)
Definition: api_memory.cpp:755
CSG_Array_Int::Inc_Array
bool Inc_Array(sLong nValues=1)
Definition: api_core.h:443
SG_Mem_Set_Double
void SG_Mem_Set_Double(char *Buffer, double Value, bool bSwapBytes)
Definition: api_memory.cpp:212
CSG_Array::Set_Growth
bool Set_Growth(TSG_Array_Growth Growth)
Definition: api_memory.cpp:302
SG_Char
#define SG_Char
Definition: api_core.h:536
CSG_Array::Inc_Array
bool Inc_Array(sLong nValues=1)
Definition: api_memory.cpp:414
CSG_Array
Definition: api_core.h:308
CSG_String
Definition: api_core.h:563
CSG_Array_Pointer
Definition: api_core.h:368
CSG_Array::Dec_Array
bool Dec_Array(bool bShrink=true)
Definition: api_memory.cpp:425
CSG_Buffer::Create
bool Create(void)
Definition: api_memory.cpp:679
TSG_Array_Growth::SG_ARRAY_GROWTH_0
@ SG_ARRAY_GROWTH_0
CSG_Array_sLong::Get_Array
sLong * Get_Array(void) const
Definition: api_core.h:495
CSG_Bytes_Array::Destroy
bool Destroy(void)
Definition: api_memory.cpp:1015
SG_Swap_Bytes
void SG_Swap_Bytes(void *Buffer, int nBytes)
Definition: api_memory.cpp:154
CSG_Array_Pointer::Add
bool Add(void *Value)
Definition: api_memory.cpp:485
CSG_Array_Pointer::Get_Array
void ** Get_Array(void) const
Definition: api_core.h:384
CSG_Array_sLong::Add
bool Add(sLong Value)
Definition: api_memory.cpp:628
CSG_String::c_str
const SG_Char * c_str(void) const
Definition: api_string.cpp:236
CSG_Array_sLong
Definition: api_core.h:479
CSG_Array::CSG_Array
CSG_Array(void)
Definition: api_memory.cpp:230
uLong
unsigned long long uLong
Definition: api_core.h:159