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