Back to index

plt-scheme  4.2.1
Functions
Attrib.c File Reference
#include "xpmP.h"

Go to the source code of this file.

Functions

 LFUNC (CreateOldColorTable, int,(XpmColor *ct, int ncolors, XpmColor ***oldct))
 LFUNC (FreeOldColorTable, void,(XpmColor **colorTable, int ncolors))
static int CreateOldColorTable (XpmColor *ct, int ncolors, XpmColor ***oldct)
static void FreeOldColorTable (XpmColor **colorTable, int ncolors)
void xpmFreeColorTable (XpmColor *colorTable, int ncolors)
void XpmFreeExtensions (XpmExtension *extensions, int nextensions)
int XpmAttributesSize ()
void xpmInitAttributes (XpmAttributes *attributes)
void xpmSetAttributes (XpmAttributes *attributes, XpmImage *image, XpmInfo *info)
void XpmFreeAttributes (XpmAttributes *attributes)

Function Documentation

static int CreateOldColorTable ( XpmColor ct,
int  ncolors,
XpmColor ***  oldct 
) [static]

Definition at line 47 of file Attrib.c.

{
    XpmColor **colorTable, **color;
    int a;

    colorTable = (XpmColor **) XpmMalloc(ncolors * sizeof(XpmColor *));
    if (!colorTable) {
       *oldct = NULL;
       return (XpmNoMemory);
    }
    for (a = 0, color = colorTable; a < ncolors; a++, color++, ct++)
       *color = ct;
    *oldct = colorTable;
    return (XpmSuccess);
}

Here is the caller graph for this function:

static void FreeOldColorTable ( XpmColor **  colorTable,
int  ncolors 
) [static]

Definition at line 67 of file Attrib.c.

{
    int a, b;
    XpmColor **color;
    char **sptr;

    if (colorTable) {
       for (a = 0, color = colorTable; a < ncolors; a++, color++) {
           for (b = 0, sptr = (char **) *color; b <= NKEYS; b++, sptr++)
              if (*sptr)
                  XpmFree(*sptr);
       }
       XpmFree(*colorTable);
       XpmFree(colorTable);
    }
}

Here is the caller graph for this function:

LFUNC ( CreateOldColorTable  ,
int  ,
(XpmColor *ct, int ncolors, XpmColor ***oldct)   
)
LFUNC ( FreeOldColorTable  ,
void  ,
(XpmColor **colorTable, int ncolors)   
)

Definition at line 142 of file Attrib.c.

{
    return sizeof(XpmAttributes);
}

Definition at line 245 of file Attrib.c.

{
    if (attributes->valuemask & XpmReturnPixels && attributes->npixels) {
       XpmFree(attributes->pixels);
       attributes->pixels = NULL;
       attributes->npixels = 0;
    }
    if (attributes->valuemask & XpmReturnColorTable) {
       xpmFreeColorTable(attributes->colorTable, attributes->ncolors);
       attributes->colorTable = NULL;
       attributes->ncolors = 0;
    }
/* 3.2 backward compatibility code */
    else if (attributes->valuemask & XpmInfos) {
       if (attributes->colorTable) {
           FreeOldColorTable((XpmColor **) attributes->colorTable,
                           attributes->ncolors);
           attributes->colorTable = NULL;
           attributes->ncolors = 0;
       }
       if (attributes->hints_cmt) {
           XpmFree(attributes->hints_cmt);
           attributes->hints_cmt = NULL;
       }
       if (attributes->colors_cmt) {
           XpmFree(attributes->colors_cmt);
           attributes->colors_cmt = NULL;
       }
       if (attributes->pixels_cmt) {
           XpmFree(attributes->pixels_cmt);
           attributes->pixels_cmt = NULL;
       }
       if (attributes->pixels) {
           XpmFree(attributes->pixels);
           attributes->pixels = NULL;
           attributes->npixels = 0;
       }
    }
/* end 3.2 bc */
    if (attributes->valuemask & XpmReturnExtensions
       && attributes->nextensions) {
       XpmFreeExtensions(attributes->extensions, attributes->nextensions);
       attributes->extensions = NULL;
       attributes->nextensions = 0;
    }
    if (attributes->valuemask & XpmReturnAllocPixels
       && attributes->nalloc_pixels) {
       XpmFree(attributes->alloc_pixels);
       attributes->alloc_pixels = NULL;
       attributes->nalloc_pixels = 0;
    }
    attributes->valuemask = 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void xpmFreeColorTable ( XpmColor colorTable,
int  ncolors 
)

Definition at line 92 of file Attrib.c.

{
    int a, b;
    XpmColor *color;
    char **sptr;

    if (colorTable) {
       for (a = 0, color = colorTable; a < ncolors; a++, color++) {
           for (b = 0, sptr = (char **) color; b <= NKEYS; b++, sptr++)
              if (*sptr)
                  XpmFree(*sptr);
       }
       XpmFree(colorTable);
    }
}

Here is the caller graph for this function:

void XpmFreeExtensions ( XpmExtension extensions,
int  nextensions 
)

Definition at line 114 of file Attrib.c.

{
    unsigned int i, j, nlines;
    XpmExtension *ext;
    char **sptr;

    if (extensions) {
       for (i = 0, ext = extensions; i < nextensions; i++, ext++) {
           if (ext->name)
              XpmFree(ext->name);
           nlines = ext->nlines;
           for (j = 0, sptr = ext->lines; j < nlines; j++, sptr++)
              if (*sptr)
                  XpmFree(*sptr);
           if (ext->lines)
              XpmFree(ext->lines);
       }
       XpmFree(extensions);
    }
}

Here is the caller graph for this function:

Definition at line 151 of file Attrib.c.

{
    if (attributes) {
       attributes->pixels = NULL;
       attributes->npixels = 0;
       attributes->colorTable = NULL;
       attributes->ncolors = 0;
/* 3.2 backward compatibility code */
       attributes->hints_cmt = NULL;
       attributes->colors_cmt = NULL;
       attributes->pixels_cmt = NULL;
/* end 3.2 bc */
       attributes->extensions = NULL;
       attributes->nextensions = 0;
       attributes->alloc_pixels = NULL;
       attributes->nalloc_pixels = 0;
    }
}

Here is the caller graph for this function:

void xpmSetAttributes ( XpmAttributes attributes,
XpmImage image,
XpmInfo info 
)

Definition at line 175 of file Attrib.c.

{
    if (attributes->valuemask & XpmReturnColorTable) {
       attributes->colorTable = image->colorTable;
       attributes->ncolors = image->ncolors;

       /* avoid deletion of copied data */
       image->ncolors = 0;
       image->colorTable = NULL;
    }
/* 3.2 backward compatibility code */
    else if (attributes->valuemask & XpmReturnInfos) {
       int ErrorStatus;

       ErrorStatus = CreateOldColorTable(image->colorTable, image->ncolors,
                                     (XpmColor ***)
                                     &attributes->colorTable);

       /* if error just say we can't return requested data */
       if (ErrorStatus != XpmSuccess) {
           attributes->valuemask &= ~XpmReturnInfos;
           if (!(attributes->valuemask & XpmReturnPixels)) {
              XpmFree(attributes->pixels);
              attributes->pixels = NULL;
              attributes->npixels = 0;
           }
           attributes->ncolors = 0;
       } else {
           attributes->ncolors = image->ncolors;
           attributes->hints_cmt = info->hints_cmt;
           attributes->colors_cmt = info->colors_cmt;
           attributes->pixels_cmt = info->pixels_cmt;

           /* avoid deletion of copied data */
           image->ncolors = 0;
           image->colorTable = NULL;
           info->hints_cmt = NULL;
           info->colors_cmt = NULL;
           info->pixels_cmt = NULL;
       }
    }
/* end 3.2 bc */
    if (attributes->valuemask & XpmReturnExtensions) {
       attributes->extensions = info->extensions;
       attributes->nextensions = info->nextensions;

       /* avoid deletion of copied data */
       info->extensions = NULL;
       info->nextensions = 0;
    }
    if (info->valuemask & XpmHotspot) {
       attributes->valuemask |= XpmHotspot;
       attributes->x_hotspot = info->x_hotspot;
       attributes->y_hotspot = info->y_hotspot;
    }
    attributes->valuemask |= XpmCharsPerPixel;
    attributes->cpp = image->cpp;
    attributes->valuemask |= XpmSize;
    attributes->width = image->width;
    attributes->height = image->height;
}

Here is the call graph for this function:

Here is the caller graph for this function: