(file) Return to StringRep.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

Diff for /pegasus/src/Pegasus/Common/StringRep.h between version 1.1.2.6 and 1.5.2.1

version 1.1.2.6, 2005/10/11 23:47:23 version 1.5.2.1, 2006/03/03 20:23:23
Line 1 
Line 1 
 //%2005////////////////////////////////////////////////////////////////////////  //%2006////////////////////////////////////////////////////////////////////////
 // //
 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
Line 8 
Line 8 
 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.; // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 // EMC Corporation; VERITAS Software Corporation; The Open Group. // EMC Corporation; VERITAS Software Corporation; The Open Group.
   // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
   // EMC Corporation; Symantec Corporation; The Open Group.
 // //
 // Permission is hereby granted, free of charge, to any person obtaining a copy // Permission is hereby granted, free of charge, to any person obtaining a copy
 // of this software and associated documentation files (the "Software"), to // of this software and associated documentation files (the "Software"), to
Line 32 
Line 34 
 #ifndef _Pegasus_StringRep_h #ifndef _Pegasus_StringRep_h
 #define _Pegasus_StringRep_h #define _Pegasus_StringRep_h
  
   #include <Pegasus/Common/Config.h>
 #include <Pegasus/Common/AtomicInt.h> #include <Pegasus/Common/AtomicInt.h>
 #include <new> #include <new>
  
Line 51 
Line 54 
  
     static StringRep* create(const char* data, size_t size);     static StringRep* create(const char* data, size_t size);
  
     static StringRep* createASCII7(const char* data, size_t size);  
   
     static StringRep* copyOnWrite(StringRep* rep);     static StringRep* copyOnWrite(StringRep* rep);
  
     static Uint32 length(const Uint16* str);     static Uint32 length(const Uint16* str);
Line 71 
Line 72 
     size_t cap;     size_t cap;
  
     // Number of string refering to this StringRep (1, 2, etc).     // Number of string refering to this StringRep (1, 2, etc).
     NewAtomicInt refs;      AtomicInt refs;
  
     // The first character in the string. Extra space is allocated off the     // The first character in the string. Extra space is allocated off the
     // end of this structure for additional characters.     // end of this structure for additional characters.
Line 80 
Line 81 
  
 inline void StringRep::free(StringRep* rep) inline void StringRep::free(StringRep* rep)
 { {
     rep->refs.~NewAtomicInt();      rep->refs.~AtomicInt();
     ::operator delete(rep);     ::operator delete(rep);
 } }
  
 inline StringRep::StringRep() : size(0), cap(0)  inline StringRep::StringRep() : size(0), cap(0), refs(2)
 { {
     // Only called on _emptyRep. We set the reference count to two to     // Only called on _emptyRep. We set the reference count to two to
     // keep a String from modifying it (if the reference count were one,     // keep a String from modifying it (if the reference count were one,
     // a string would think it was the sole owner of the StringRep object).     // a string would think it was the sole owner of the StringRep object).
     new(&refs) NewAtomicInt();  
     data[0] = 0;     data[0] = 0;
 } }
  
 inline StringRep::~StringRep() inline StringRep::~StringRep()
 { {
     // Only called on _emptyRep.     // Only called on _emptyRep.
     refs.~NewAtomicInt();  
 } }
  
 inline void StringRep::ref(const StringRep* rep) inline void StringRep::ref(const StringRep* rep)
 { {
     if (rep != &StringRep::_emptyRep)     if (rep != &StringRep::_emptyRep)
         ((StringRep*)rep)->refs.inc();          ((StringRep*)rep)->refs++;
 } }
  
 inline void StringRep::unref(const StringRep* rep) inline void StringRep::unref(const StringRep* rep)
 { {
     if (rep != &StringRep::_emptyRep && ((StringRep*)rep)->refs.dec_and_test())      if (rep != &StringRep::_emptyRep &&
           ((StringRep*)rep)->refs.decAndTestIfZero())
         StringRep::free((StringRep*)rep);         StringRep::free((StringRep*)rep);
 } }
  


Legend:
Removed from v.1.1.2.6  
changed lines
  Added in v.1.5.2.1

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2