4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Jonghyuk Choi <jhchoi.choi@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
28 #include <mm_list_private.h>
31 * Definition of list item
42 static mmf_list_t *g_list = NULL;
43 static int g_list_id = 0;
46 int mmf_list_append(void *data)
51 item = (mmf_list_t *) malloc(sizeof(mmf_list_t));
54 debug_error("memory allocation error\n");
55 return MM_ERROR_OUT_OF_MEMORY;
58 /* set new list information */
59 memset(item, 0, sizeof(mmf_list_t));
61 item->id = g_list_id++;
74 list = (mmf_list_t *) list->next;
83 int mmf_list_remove(int handle)
92 if (list->id == handle) {
95 prev->next = list->next;
103 return MM_ERROR_NONE;
107 list = (mmf_list_t *) list->next;
110 debug_error("handle not found\n");
112 return MM_ERROR_INVALID_ARGUMENT;
116 void *mmf_list_find(int handle)
123 if (list->id == handle) {
127 list = (mmf_list_t *) list->next;
130 debug_error("handle not found\n");
136 int mmf_list_find_by_data(void *data)
143 if (list->data == data) {
147 list = (mmf_list_t *) list->next;
150 debug_error("handle not found\n");