File: Cache_Manager.cpp

package info (click to toggle)
ace 6.0.3%2Bdfsg-0.1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 49,368 kB
  • sloc: cpp: 341,826; perl: 30,850; ansic: 20,952; makefile: 10,144; sh: 4,744; python: 828; exp: 787; yacc: 511; xml: 330; lex: 158; lisp: 116; csh: 48; tcl: 5
file content (99 lines) | stat: -rw-r--r-- 1,803 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// $Id: Cache_Manager.cpp 80826 2008-03-04 14:51:23Z wotte $

#include "ace/ACE.h"
#include "ace/OS_NS_string.h"

#include "JAWS/Cache_Manager.h"
#include "JAWS/Cache_List_T.h"

JAWS_String_Hash_Functor::JAWS_String_Hash_Functor (const char *s)
  : i_ (0)
{
  this->i_ = ACE::hash_pjw (s);
}

JAWS_String_Hash_Functor::operator unsigned long (void) const
{
  return this->i_;
}

JAWS_String_Equal_Functor::JAWS_String_Equal_Functor (const char *s1,
                                                    const char *s2)
  : i_ (0)
{
  this->i_ = ACE_OS::strcmp (s1, s2);
}

JAWS_String_Equal_Functor::operator int (void) const
{
  return this->i_ == 0;
}

JAWS_Strdup_String::JAWS_Strdup_String (void)
  : c_ (0),
    s_ (0)
{
}

JAWS_Strdup_String::JAWS_Strdup_String (const char *s)
  : c_ (0),
    s_ (0)
{
  this->c_ = new int (1);
  this->s_ = ACE_OS::strdup (s);
}

JAWS_Strdup_String::JAWS_Strdup_String (const JAWS_Strdup_String &s)
  : c_ (s.c_),
    s_ (s.s_)
{
  ++*(this->c_);
}

JAWS_Strdup_String::~JAWS_Strdup_String (void)
{
  if (this->c_ && --*(this->c_) == 0)
    {
      if (this->s_)
        ACE_OS::free (this->s_);
      delete this->c_;
    }
  this->s_ = 0;
  this->c_ = 0;
}

JAWS_Strdup_String::operator const char * (void) const
{
  return this->s_;
}

void
JAWS_Strdup_String::operator = (const char *s)
{
  if (this->c_ && --*(this->c_) == 0)
    {
      if (this->s_)
        ACE_OS::free (this->s_);
      delete this->c_;
    }
  this->c_ = new int (1);
  this->s_ = ACE_OS::strdup (s);
}

void
JAWS_Strdup_String::operator = (const JAWS_Strdup_String &s)
{
  if (this == &s)
    return;

  if (this->c_ && --*(this->c_) == 0)
    {
      if (this->s_)
        ACE_OS::free (this->s_);
      delete this->c_;
    }
  this->c_ = s.c_;
  this->s_ = s.s_;
  ++*(this->c_);
}