compile fix: ISO C++ forbids variable length array 'names'

This commit is contained in:
Mathias Gumz 2009-09-30 21:05:42 +02:00
parent f8c61a1ba2
commit 9cd953b2e1
2 changed files with 10 additions and 6 deletions

View file

@ -822,7 +822,7 @@ void Ewmh::updateWorkspaceNames(BScreen &screen) {
const BScreen::WorkspaceNames &workspacenames = screen.getWorkspaceNames(); const BScreen::WorkspaceNames &workspacenames = screen.getWorkspaceNames();
const size_t number_of_desks = workspacenames.size(); const size_t number_of_desks = workspacenames.size();
char *names[number_of_desks]; char** names = new char*[number_of_desks];
for (size_t i = 0; i < number_of_desks; i++) { for (size_t i = 0; i < number_of_desks; i++) {
names[i] = new char[workspacenames[i].size() + 1]; // +1 for \0 names[i] = new char[workspacenames[i].size() + 1]; // +1 for \0
@ -850,7 +850,9 @@ void Ewmh::updateWorkspaceNames(BScreen &screen) {
#endif #endif
for (size_t i = 0; i < number_of_desks; i++) for (size_t i = 0; i < number_of_desks; i++)
delete [] names[i]; delete[] names[i];
delete[] names;
} }

View file

@ -228,7 +228,7 @@ void Gnome::updateWorkspaceNames(BScreen &screen) {
size_t number_of_desks = screen.getWorkspaceNames().size(); size_t number_of_desks = screen.getWorkspaceNames().size();
const BScreen::WorkspaceNames &workspace_names = screen.getWorkspaceNames(); const BScreen::WorkspaceNames &workspace_names = screen.getWorkspaceNames();
// convert our desktop names to a char * so we can send it // convert our desktop names to a char * so we can send it
char *names[number_of_desks]; char** names = new char*[number_of_desks];
for (size_t i = 0; i < number_of_desks; i++) { for (size_t i = 0; i < number_of_desks; i++) {
names[i] = new char[workspace_names[i].size() + 1]; names[i] = new char[workspace_names[i].size() + 1];
@ -244,7 +244,9 @@ void Gnome::updateWorkspaceNames(BScreen &screen) {
// destroy name buffers // destroy name buffers
for (size_t i = 0; i < number_of_desks; i++) for (size_t i = 0; i < number_of_desks; i++)
delete [] names[i]; delete[] names[i];
delete[] names;
} }
void Gnome::updateCurrentWorkspace(BScreen &screen) { void Gnome::updateCurrentWorkspace(BScreen &screen) {