Loading src/connection.h +10 −15 Changes for src/connection.h: 10 added lines, 15 removed lines. Original line number Diff line number Diff line /******************************************************************************* * Copyright (c) 2014, Jan Koester jan.koester@gmx.net * All rights reserved. * * Redistribution and use in source and binary forms, with or without * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. Loading @@ -12,8 +11,7 @@ * Neither the name of the <organization> nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY Loading Loading @@ -95,28 +93,24 @@ namespace netplus { // allocate but don't initialize num elements of type T pointer allocate (size_type num, const void* = 0) { if (num == 0) return nullptr; T* ptr = (T*)malloc(num * sizeof(T)); if (ptr == nullptr) throw std::bad_alloc(); return ptr; // ::operator new throws std::bad_alloc on failure, making this compliant. pointer ret = (pointer)(::operator new(num*sizeof(T))); return ret; } // initialize elements of allocated storage p with value value void construct (pointer p, const T& value) noexcept { // or throw() void construct (pointer p, const T& value) noexcept { // ADDED noexcept new((void*)p)T(value); } // destroy elements of initialized storage p void destroy (pointer p) noexcept{ void destroy (pointer p) noexcept { // ADDED noexcept p->~T(); } // deallocate storage p of deleted elements void deallocate (pointer p, size_type num) { free((void*)p); void deallocate (pointer p, size_type num) noexcept { // ADDED noexcept ::operator delete((void*)p); } }; Loading Loading @@ -149,6 +143,7 @@ namespace netplus { iterator end(); const_iterator end() const; void resize(size_t size_c); void append(const char *data,size_t datalen); size_t search(const char *word); Loading Loading
src/connection.h +10 −15 Changes for src/connection.h: 10 added lines, 15 removed lines. Original line number Diff line number Diff line /******************************************************************************* * Copyright (c) 2014, Jan Koester jan.koester@gmx.net * All rights reserved. * * Redistribution and use in source and binary forms, with or without * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. Loading @@ -12,8 +11,7 @@ * Neither the name of the <organization> nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY Loading Loading @@ -95,28 +93,24 @@ namespace netplus { // allocate but don't initialize num elements of type T pointer allocate (size_type num, const void* = 0) { if (num == 0) return nullptr; T* ptr = (T*)malloc(num * sizeof(T)); if (ptr == nullptr) throw std::bad_alloc(); return ptr; // ::operator new throws std::bad_alloc on failure, making this compliant. pointer ret = (pointer)(::operator new(num*sizeof(T))); return ret; } // initialize elements of allocated storage p with value value void construct (pointer p, const T& value) noexcept { // or throw() void construct (pointer p, const T& value) noexcept { // ADDED noexcept new((void*)p)T(value); } // destroy elements of initialized storage p void destroy (pointer p) noexcept{ void destroy (pointer p) noexcept { // ADDED noexcept p->~T(); } // deallocate storage p of deleted elements void deallocate (pointer p, size_type num) { free((void*)p); void deallocate (pointer p, size_type num) noexcept { // ADDED noexcept ::operator delete((void*)p); } }; Loading Loading @@ -149,6 +143,7 @@ namespace netplus { iterator end(); const_iterator end() const; void resize(size_t size_c); void append(const char *data,size_t datalen); size_t search(const char *word); Loading