2 * BadAllocationException.cxx
\r
4 * Copyright 2006,2007 Martin Quinson, Malek Cherier
\r
5 * All right reserved.
\r
7 * This program is free software; you can redistribute
\r
8 * it and/or modify it under the terms of the license
\r
9 *(GNU LGPL) which comes with this package.
\r
13 /* BadAllocationException member functions implementation.
\r
16 #include <BadAllocException.hpp>
\r
27 BadAllocException::BadAllocException()
\r
29 this->reason = (char*) calloc(strlen("Not enough memory") + 1, sizeof(char));
\r
30 strcpy(this->reason, "Not enough memory");
\r
34 BadAllocException::BadAllocException(const BadAllocException& rBadAllocException)
\r
36 const char* reason = rBadAllocException.toString();
\r
37 this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));
\r
38 strcpy(this->reason, reason);
\r
42 BadAllocException::BadAllocException(const char* objectName)
\r
44 this->reason = (char*) calloc(strlen("Not enough memory to allocate ") + strlen(objectName) + 1, sizeof(char));
\r
45 sprintf(this->reason, "Not enough memory to allocate %s", objectName);
\r
49 BadAllocException::~BadAllocException()
\r
55 const char* BadAllocException::toString(void) const
\r
57 return (const char*)(this->reason);
\r
61 const BadAllocException& BadAllocException::operator = (const BadAllocException& rBadAllocException)
\r
63 const char* reason = rBadAllocException.toString();
\r
64 this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));
\r
71 }// namespace SimGrid
\r