]> git.saurik.com Git - apt.git/blame - apt-pkg/pkgsystem.cc
Fix double free (closes: #711045)
[apt.git] / apt-pkg / pkgsystem.cc
CommitLineData
b2e465d6
AL
1// -*- mode: cpp; mode: fold -*-
2// Description /*{{{*/
cb063009 3// $Id: pkgsystem.cc,v 1.3 2004/02/27 00:43:16 mdz Exp $
b2e465d6
AL
4/* ######################################################################
5
6 System - Abstraction for running on different systems.
7
8 Basic general structure..
9
10 ##################################################################### */
11 /*}}}*/
12// Include Files /*{{{*/
ea542140
DK
13#include<config.h>
14
b2e465d6
AL
15#include <apt-pkg/pkgsystem.h>
16#include <apt-pkg/policy.h>
cb063009 17#include <cassert>
4f333a8b 18#include <cstring>
b2e465d6
AL
19 /*}}}*/
20
21pkgSystem *_system = 0;
22static pkgSystem *SysList[10];
23pkgSystem **pkgSystem::GlobalList = SysList;
24unsigned long pkgSystem::GlobalListLen = 0;
25
26// System::pkgSystem - Constructor /*{{{*/
27// ---------------------------------------------------------------------
28/* Add it to the global list.. */
dcaa1185 29pkgSystem::pkgSystem() : Label(NULL), VS(NULL)
b2e465d6 30{
cb063009 31 assert(GlobalListLen < sizeof(SysList)/sizeof(*SysList));
b2e465d6 32 SysList[GlobalListLen] = this;
dcaa1185 33 ++GlobalListLen;
b2e465d6
AL
34}
35 /*}}}*/
36// System::GetSystem - Get the named system /*{{{*/
37// ---------------------------------------------------------------------
38/* */
39pkgSystem *pkgSystem::GetSystem(const char *Label)
40{
41 for (unsigned I = 0; I != GlobalListLen; I++)
42 if (strcmp(SysList[I]->Label,Label) == 0)
43 return SysList[I];
44 return 0;
45}
46 /*}}}*/