diff --git a/src/core.c b/src/core.c index 88f0af9..8e831e0 100644 --- a/src/core.c +++ b/src/core.c @@ -93,8 +93,7 @@ static void llkeyrelhandler(MwLL handle, void* data) { MwWidget MwCreateWidget(MwClass widget_class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height) { MwWidget h = malloc(sizeof(*h)); - h->name = malloc(strlen(name) + 1); - strcpy(h->name, name); + h->name = MwStringDupliacte(name); h->parent = parent; h->children = NULL; @@ -270,8 +269,7 @@ void MwSetText(MwWidget handle, const char* key, const char* value) { if(strcmp(key, MwNtitle) == 0) { MwLLSetTitle(handle->lowlevel, value); } else { - char* v = malloc(strlen(value) + 1); - strcpy(v, value); + char* v = MwStringDupliacte(value); if(shgeti(handle->text, key) != -1) free(shget(handle->text, key)); diff --git a/src/directory.c b/src/directory.c index 14a5532..747d3db 100644 --- a/src/directory.c +++ b/src/directory.c @@ -64,8 +64,7 @@ MwDirectoryEntry* MwDirectoryRead(void* handle) { free(entry); return NULL; } - entry->name = malloc(strlen(dir->ffd.cFileName) + 1); - strcpy(entry->name, dir->ffd.cFileName); + entry->name = MwStringDupliacte(dir->ffd.cFileName); if(dir->ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { entry->type = MwDIRECTORY_DIRECTORY; @@ -80,8 +79,7 @@ MwDirectoryEntry* MwDirectoryRead(void* handle) { free(entry); return NULL; } - entry->name = malloc(strlen(d->d_name) + 1); - strcpy(entry->name, d->d_name); + entry->name = MwStringDupliacte(d->d_name); p = malloc(strlen(dir->base) + 1 + strlen(d->d_name) + 1); strcpy(p, dir->base); diff --git a/src/widget/listbox.c b/src/widget/listbox.c index 3c0f0b0..5c6e69f 100644 --- a/src/widget/listbox.c +++ b/src/widget/listbox.c @@ -248,8 +248,7 @@ void MwListBoxInsert(MwWidget handle, int index, const char* text, MwLLPixmap pi MwListBox lb = handle->internal; MwListBoxEntry entry; - entry.name = malloc(strlen(text) + 1); - strcpy(entry.name, text); + entry.name = MwStringDupliacte(text); entry.pixmap = pixmap; @@ -272,8 +271,7 @@ void MwListBoxInsertMultiple(MwWidget handle, int index, char** text, MwLLPixmap for(i = 0; i < count; i++) { MwListBoxEntry entry; - entry.name = malloc(strlen(text[i]) + 1); - strcpy(entry.name, text[i]); + entry.name = MwStringDupliacte(text[i]); entry.pixmap = NULL; if(pixmap != NULL) entry.pixmap = pixmap[i]; diff --git a/src/widget/menu.c b/src/widget/menu.c index bf9927e..f095a39 100644 --- a/src/widget/menu.c +++ b/src/widget/menu.c @@ -193,13 +193,11 @@ MwClass MwMenuClass = &MwMenuClassRec; MwMenu MwMenuAdd(MwWidget handle, MwMenu menu, const char* name) { MwMenu m = menu == NULL ? handle->internal : menu; MwMenu new = malloc(sizeof(*new)); - new->name = malloc(strlen(name) + 1); + new->name = MwStringDupliacte(name); new->sub = NULL; new->wsub = NULL; new->keep = 0; - strcpy(new->name, name); - arrput(m->sub, new); set_xywh(handle);