Browse Source

Alexandru Costache patch for memory allocation failure.

tags/v1.9.11-RC1
Stephane Letz 10 years ago
parent
commit
81c129c1dd
2 changed files with 22 additions and 0 deletions
  1. +21
    -0
      common/JackShmMem.h
  2. +1
    -0
      common/jack/jack.h

+ 21
- 0
common/JackShmMem.h View File

@@ -151,6 +151,7 @@ class JackShmReadWritePtr
private:

jack_shm_info_t fInfo;
bool fInitDone;

void Init(int index, const char* server_name = JACK_DEFAULT_SERVER_NAME)
{
@@ -164,6 +165,7 @@ class JackShmReadWritePtr
throw std::bad_alloc();
}
GetShmAddress()->LockMemory();
fInitDone = true;
}
}

@@ -172,6 +174,7 @@ class JackShmReadWritePtr
JackShmReadWritePtr()
{
fInfo.index = -1;
fInitDone = false;
fInfo.ptr.attached_at = (char*)NULL;
}

@@ -182,6 +185,10 @@ class JackShmReadWritePtr

~JackShmReadWritePtr()
{
if (!fInitDone) {
jack_error("JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for %ld, skipping unlock", fInfo.index);
return;
}
if (fInfo.index >= 0) {
jack_log("JackShmReadWritePtr::~JackShmReadWritePtr %ld", fInfo.index);
GetShmAddress()->UnlockMemory();
@@ -233,6 +240,7 @@ class JackShmReadWritePtr1
private:

jack_shm_info_t fInfo;
bool fInitDone;

void Init(int index, const char* server_name = JACK_DEFAULT_SERVER_NAME)
{
@@ -246,6 +254,7 @@ class JackShmReadWritePtr1
throw std::bad_alloc();
}
GetShmAddress()->LockMemory();
fInitDone = true;
/*
nobody else needs to access this shared memory any more, so
destroy it. because we have our own attachment to it, it won't
@@ -260,6 +269,7 @@ class JackShmReadWritePtr1
JackShmReadWritePtr1()
{
fInfo.index = -1;
fInitDone = false;
fInfo.ptr.attached_at = NULL;
}

@@ -270,6 +280,10 @@ class JackShmReadWritePtr1

~JackShmReadWritePtr1()
{
if (!fInitDone) {
jack_error("JackShmReadWritePtr1::~JackShmReadWritePtr1 - Init not done for %ld, skipping unlock", fInfo.index);
return;
}
if (fInfo.index >= 0) {
jack_log("JackShmReadWritePtr1::~JackShmReadWritePtr1 %ld", fInfo.index);
GetShmAddress()->UnlockMemory();
@@ -321,6 +335,7 @@ class JackShmReadPtr
private:

jack_shm_info_t fInfo;
bool fInitDone;

void Init(int index, const char* server_name = JACK_DEFAULT_SERVER_NAME)
{
@@ -334,6 +349,7 @@ class JackShmReadPtr
throw std::bad_alloc();
}
GetShmAddress()->LockMemory();
fInitDone = true;
}
}

@@ -342,6 +358,7 @@ class JackShmReadPtr
JackShmReadPtr()
{
fInfo.index = -1;
fInitDone = false;
fInfo.ptr.attached_at = NULL;
}

@@ -352,6 +369,10 @@ class JackShmReadPtr

~JackShmReadPtr()
{
if (!fInitDone) {
jack_error("JackShmReadPtr::~JackShmReadPtr - Init not done for %ld, skipping unlock", fInfo.index);
return;
}
if (fInfo.index >= 0) {
jack_log("JackShmPtrRead::~JackShmPtrRead %ld", fInfo.index);
GetShmAddress()->UnlockMemory();


+ 1
- 0
common/jack/jack.h View File

@@ -1443,6 +1443,7 @@ void jack_set_info_function (void (*func)(const char *)) JACK_OPTIONAL_WEAK_EXPO
* This is MANDATORY on Windows when otherwise all nasty runtime version related crashes can occur.
* Developers are strongly encouraged to use this function instead of the standard "free" function in new code.
*
* @param ptr the memory pointer to be deallocated.
*/
void jack_free(void* ptr) JACK_OPTIONAL_WEAK_EXPORT;



Loading…
Cancel
Save