| 381 | } |
| 382 | |
| 383 | void GenericPageList::SaveSelected(CEdit *description) { |
| 384 | CString new_descrip; |
| 385 | char *new_text; |
| 386 | char *old_text; |
| 387 | |
| 388 | if (m_SelectedNode == NULL) |
| 389 | return; |
| 390 | |
| 391 | // Get pointer to old text |
| 392 | old_text = m_SelectedNode->genericpage.objinfo_struct.description; |
| 393 | |
| 394 | // Get Copy of new Description text |
| 395 | description->GetWindowText(new_descrip); |
| 396 | new_text = (char *)mem_malloc(strlen(new_descrip.GetBuffer(0)) + 1); |
| 397 | ASSERT(new_text); // out of memory! |
| 398 | sprintf(new_text, "%s", new_descrip.GetBuffer(0)); |
| 399 | |
| 400 | // Check if new description is empty, if it is, make it NULL |
| 401 | if (strlen(new_text) == 0 || stricmp(new_text, NO_DESCRIPTION_STRING) == 0) { |
| 402 | mem_free(new_text); |
| 403 | new_text = NULL; |
| 404 | } |
| 405 | |
| 406 | // If both new and old are empty, get outta here |
| 407 | if (old_text == NULL && new_text == NULL) { |
| 408 | mem_free(new_text); |
| 409 | return; |
| 410 | } |
| 411 | |
| 412 | // If both have descriptions and they match, get outta here |
| 413 | if (old_text != NULL && new_text != NULL) { |
| 414 | if (strcmp(old_text, new_text) == 0) { |
| 415 | mem_free(new_text); |
| 416 | return; |
| 417 | } |
| 418 | } |
| 419 | |
| 420 | // Free up the old text memory, and assign it to the new text |
| 421 | if (old_text != NULL) |
| 422 | mem_free(old_text); |
| 423 | |
| 424 | m_SelectedNode->genericpage.objinfo_struct.description = new_text; |
| 425 | m_TableModified = TRUE; |
| 426 | |
| 427 | return; |
| 428 | } |
| 429 | |
| 430 | GenericPageNode *GenericPageList::FindNode(uint32_t page_id) { |
| 431 | GenericPageNode *node, *found_node; |
no test coverage detected