-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
libmycms: mycms-list-str: initial add
- Loading branch information
Showing
7 changed files
with
85 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#ifndef __MYCMS_LIST_STR_H | ||
#define __MYCMS_LIST_STR_H | ||
|
||
#include "mycms-system.h" | ||
#include "mycms-list.h" | ||
|
||
MYCMS_LIST_DECLARE(str, char *, str) | ||
|
||
bool | ||
mycms_list_str_add( | ||
const mycms_system system, | ||
mycms_list_str * const head, | ||
const char * const str | ||
); | ||
|
||
bool | ||
mycms_list_str_free( | ||
const mycms_system system, | ||
const mycms_list_str head | ||
); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#ifdef HAVE_CONFIG_H | ||
#include <config.h> | ||
#endif | ||
|
||
#include <mycms/mycms-list-str.h> | ||
|
||
bool | ||
mycms_list_str_add( | ||
const mycms_system system, | ||
mycms_list_str * const head, | ||
const char * const str | ||
) { | ||
bool ret = false; | ||
|
||
mycms_list_str t; | ||
if ((t = mycms_system_zalloc(system, "mycms_list_str_add.new", sizeof(*t))) == NULL) { | ||
goto cleanup; | ||
} | ||
if ((t->str = mycms_system_strdup(system, "mycms_list_str_add.dup", str)) == NULL) { | ||
goto cleanup; | ||
} | ||
|
||
if (*head == NULL) { | ||
*head = t; | ||
} else { | ||
mycms_list_str i; | ||
for (i = *head;i->next != NULL; i = i->next); | ||
i->next = t; | ||
} | ||
|
||
ret = true; | ||
|
||
cleanup: | ||
|
||
return ret; | ||
} | ||
|
||
bool | ||
mycms_list_str_free( | ||
const mycms_system system, | ||
const mycms_list_str head | ||
) { | ||
mycms_list_str h = head; | ||
while (h != NULL) { | ||
mycms_list_str t = h; | ||
h = h->next; | ||
mycms_system_free(system, "mycms_list_str_free.str", t->str); | ||
mycms_system_free(system, "mycms_list_str_free", t); | ||
} | ||
|
||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
mycms_list_str_add | ||
mycms_list_str_free |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters