Opened 17 years ago

Closed 15 years ago

#2133 closed defect (duplicate)

Use of static var in MapScript mapObj.nextLabel

Reported by: dmorissette Owned by: dmorissette
Priority: normal Milestone: 6.0 release
Component: MapServer C Library Version:
Severity: normal Keywords:
Cc: sdlime

Description (last modified by dmorissette)

While working on the implementation of label priority, I noticed that the mapObj.nextLabel() method uses a static variable to iterate over labels. This is not safe for multi-thread environments, and does not allow using the function more than once per instance of label cache.

The same code is present in mapscript/swiginc/map.i and in mapscript/php3/mapscript_i.c

What do we want to do to fix it?

  labelCacheMemberObj *nextLabel() {
    static int i=0;

    if(i<self->labelcache.numlabels)
      return &(self->labelcache.labels[i++]);
    else
      return NULL;	
  }

Change History (5)

comment:1 by dmorissette, 17 years ago

Description: modified (diff)
Summary: Use of static var in MapScript labelCacheObj.nextLabelUse of static var in MapScript mapObj.nextLabel

comment:2 by tbonfort, 16 years ago

Component: AGGMapServer C Library

comment:3 by dmorissette, 16 years ago

Milestone: 5.4 release

comment:4 by dmorissette, 15 years ago

Milestone: 5.4 release6.0 release

comment:5 by dmorissette, 15 years ago

Resolution: duplicate
Status: newclosed

Closing as duplicate of #1794.

Note: See TracTickets for help on using tickets.