]>
cygwin.com Git - cygwin-apps/setup.git/blob - category_list.cc
2 * Copyright (c) 2001, Robert Collins.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * A copy of the GNU General Public License can be found at
12 * Written by Robert Collins <rbtcollins@hotmail.com>
16 /* categories for packages */
21 #include "category_list.h"
24 CategoryList::CategoryList ():_categories (0), ncategories (0),
29 Category
& CategoryList::register_category (const char *catname
)
33 getcategorybyname (catname
);
36 if (ncategories
== categoriesspace
)
39 newcategories
= (Category
**)
41 sizeof (Category
*) * (categoriesspace
+ 20));
47 _categories
= newcategories
;
48 if (categoriesspace
== 0)
50 categoriesspace
+= 20;
52 tempcat
= new Category (catname
);
56 && strcasecmp (_categories
[n
]->name
, tempcat
->name
) < 0; n
++);
59 _categories
[n
- 1]->next
= tempcat
;
61 tempcat
->next
= _categories
[n
];
62 memmove (&_categories
[n
+ 1], &_categories
[n
],
63 (ncategories
- n
) * sizeof (Category
*));
64 _categories
[n
] = tempcat
;
71 CategoryList::getcategorybyname (const char *name
)
73 for (size_t n
= 0; n
< ncategories
; n
++)
74 if (strcasecmp (_categories
[n
]->name
, name
) == 0)
75 return _categories
[n
];
This page took 0.037571 seconds and 5 git commands to generate.