Commit dfd2baa3 authored by claes's avatar claes

*** empty log message ***

parent ba8439e7
......@@ -523,9 +523,6 @@ int Admin::open_input()
else
XmTextSetString( text_w, "");
if ( value)
XtFree( value);
message( ' ', "");
flow_SetInputFocus( text_w);
set_prompt( "admin >");
......
......@@ -15,7 +15,8 @@ wb_adrep *wb_adrep::ref()
return this;
}
wb_adrep::wb_adrep( wb_orepdbs& o): m_nRef(0), m_orep(&o), m_sts(LDH__SUCCESS)
wb_adrep::wb_adrep( wb_orepdbs& o): m_nRef(0), m_orep(&o), m_sts(LDH__SUCCESS),
m_bufferClass(pwr_eClass__)
{
m_orep->ref();
......@@ -110,6 +111,7 @@ wb_adrep::wb_adrep( wb_orepdbs& o): m_nRef(0), m_orep(&o), m_sts(LDH__SUCCESS)
m_paramindex = attr.Info.ParamIndex;
m_flags = attr.Info.Flags;
m_tid = 0;
m_bufferClass = attr.Class;
break;
}
......
......@@ -22,6 +22,7 @@ class wb_adrep
int m_flags;
pwr_tTid m_tid;
pwr_tPgmName m_pgmname;
pwr_eClass m_bufferClass;
friend class wb_bdrep;
friend class wb_cdrep;
......@@ -51,6 +52,7 @@ class wb_adrep
int bix();
int flags() {return m_flags;}
pwr_tOid boid();
pwr_eClass bufferClass() { return m_bufferClass;}
const char *name() const;
wb_name longName();
......
......@@ -58,8 +58,30 @@ wb_attribute::wb_attribute(pwr_tStatus sts, wb_orep * const orep, wb_adrep * con
}
}
wb_attribute::wb_attribute(pwr_tStatus sts, wb_orep * const orep, const char *aname, const char *bname) :
wb_status(sts), m_orep(orep)
wb_attribute::wb_attribute(pwr_tStatus sts, wb_orep * const orep, const char *bname) :
wb_status(sts), m_orep(orep), m_adrep(0), m_size(0), m_offset(0), m_tid(0),
m_elements(0), m_type(pwr_eType_), m_flags(0)
{
if ( orep == 0)
m_sts = LDH__NOSUCHATTR;
else {
wb_cdrep *cd = m_orep->vrep()->merep()->cdrep( &m_sts, m_orep->cid());
if ( oddSts()) {
wb_bdrep *bd = cd->bdrep( &m_sts, bname);
if ( oddSts()) {
m_size = bd->size();
delete bd;
}
delete cd;
}
if ( oddSts())
m_orep->ref();
}
}
wb_attribute::wb_attribute(pwr_tStatus sts, wb_orep * const orep, char const *bname, const char *aname) :
wb_status(sts), m_orep(orep), m_adrep(0), m_size(0), m_offset(0), m_tid(0),
m_elements(0), m_type(pwr_eType_), m_flags(0)
{
if ( orep == 0)
m_sts = LDH__NOSUCHATTR;
......@@ -205,6 +227,14 @@ pwr_tOid wb_attribute::boid()
return oid; // Fix
}
pwr_eClass wb_attribute::bufferClass()
{
// This is not recursive for subclasses
if ( m_adrep)
return m_adrep->bufferClass();
return pwr_eClass__;
}
bool wb_attribute::checkXref()
{
return true; // Fix
......
......@@ -42,11 +42,12 @@ public:
wb_attribute(const wb_attribute&);
wb_attribute(pwr_tStatus, wb_orep* const );
wb_attribute(pwr_tStatus, wb_orep* const, wb_adrep* const);
wb_attribute(pwr_tStatus, wb_orep* const, const char* aname, const char* bname = 0);
wb_attribute(pwr_tStatus, wb_orep* const, const char* bname);
wb_attribute(pwr_tStatus, wb_orep* const, const char* aname, const char* bname);
~wb_attribute();
wb_attribute& operator=(const wb_attribute&);
operator bool() const { return evenSts();}
operator bool() const { return oddSts();}
operator wb_orep*() const;
bool operator==(wb_attribute&);
......@@ -69,6 +70,7 @@ public:
bool checkXref();
pwr_sAttrXRef *xref();
pwr_sObjXRef *oxref();
pwr_eClass bufferClass();
void *value( void *p = 0);
void *value(void *vp, size_t size, pwr_tStatus*);
......
......@@ -81,6 +81,7 @@ int wb_bdrep::nAttribute()
case pwr_eClass_Output:
case pwr_eClass_ObjXRef:
case pwr_eClass_AttrXRef:
case pwr_eClass_Buffer:
attr_count++;
break;
default:
......
......@@ -548,9 +548,9 @@ ldh_GetObjectBody(ldh_tSession session, pwr_tOid oid, char *bname, void **buff,
wb_object o = sp->object(oid);
wb_attribute a = sp->attribute(o, bname);
*buff = XtMalloc(a.size());
*buff = malloc(a.size());
if (*buff == NULL) return LDH__INSVIRMEM;
memcpy(*buff, a.value( 0), a.size());
a.value( *buff);
if (size != NULL) *size = a.size();
return LDH__SUCCESS;
......@@ -591,14 +591,10 @@ ldh_GetObjectBuffer(ldh_tSession session, pwr_tOid oid, char *bname,
*value = (char *)calloc(1, a.size());
*size = a.size();
//*bufferclass = a.?;
//wb_value v(value, size);
//if (!v) return v.sts();
//v = a.value();
//return v.sts();
return LDH__NYI;
a.value( value);
*bufferclass = a.bufferClass();
return LDH__SUCCESS;
}
pwr_tStatus
......@@ -647,9 +643,9 @@ ldh_GetObjectPar(ldh_tSession session, pwr_tOid oid, char *bname, char *aname, c
*buff = (char *)calloc(1, a.size());
if (*buff == NULL) return LDH__INSVIRMEM;
memcpy(*buff, a.value(), a.size());
a.value( *buff);
if (size != 0)
*size = a.size();
*size = a.size();
return a.sts();
}
......
......@@ -371,7 +371,7 @@ int ItemObject::open_attributes( Nav *nav, double x, double y)
bodydef[i].Par->Param.Info.Type, is_root);
}
}
XtFree( (char *)bodydef);
free( (char *)bodydef);
}
if ( attr_exist && !is_root)
......
......@@ -197,7 +197,7 @@ wb_cdef wb_volume::cdef(wb_name n)
return wb_cdef(m_vrep->merep()->cdrep( &sts, n));
}
wb_attribute wb_volume::attribute(pwr_tOid oid, const char *aname, const char *bname) const
wb_attribute wb_volume::attribute(pwr_tOid oid, const char *bname, const char *aname) const
{
pwr_tStatus sts;
wb_orep *orep;
......@@ -209,7 +209,24 @@ wb_attribute wb_volume::attribute(pwr_tOid oid, const char *aname, const char *b
// Other volume
orep = m_vrep->erep()->object(&sts, oid);
wb_attribute a = wb_attribute(sts, orep, aname, bname);
wb_attribute a = wb_attribute(sts, orep, bname, aname);
return a;
}
wb_attribute wb_volume::attribute(pwr_tOid oid, const char *bname) const
{
pwr_tStatus sts;
wb_orep *orep;
if (oid.vid == m_vrep->vid())
// This volume
orep = m_vrep->object( &sts, oid);
else
// Other volume
orep = m_vrep->erep()->object(&sts, oid);
wb_attribute a = wb_attribute(sts, orep, bname);
return a;
}
......
......@@ -51,7 +51,8 @@ public:
wb_object object(pwr_tCid cid) const { wb_object o; return o;} // Fix
wb_object object(const char *name) const;
wb_attribute attribute(pwr_tOid oid, const char *aname, const char *bname) const;
wb_attribute attribute(pwr_tOid oid, const char *bname, const char *aname) const;
wb_attribute attribute(pwr_tOid oid, const char *bname) const;
wb_attribute attribute(wb_object o, wb_adef adef) { wb_attribute a; return a;}; // Fix
wb_attribute attribute(wb_object o, wb_name aname) { wb_attribute a; return a;}; // Fix
wb_attribute attribute(wb_name aname) { wb_attribute a; return a;}; // Fix
......
......@@ -201,11 +201,11 @@ wb_vrepdbs::readAttribute(pwr_tStatus *sts, wb_orep *o, cdh_eBix bix, unsigned i
return 0;
if (p) {
memcpy(p, bp, MIN(op->rbody.size, size));
memcpy(p, (char *)bp + offset, MIN(op->rbody.size - offset, size));
return p;
}
return bp;
return (void *)((char *)bp + offset);
}
......
......@@ -78,7 +78,7 @@ void WVsel::vsel_activate_ok (
int i;
pwr_tVolumeId *volume_ptr;
volume_ptr = (pwr_tVolumeId *) XtCalloc( vsel->volume_count,
volume_ptr = (pwr_tVolumeId *) calloc( vsel->volume_count,
sizeof( pwr_tVolumeId));
if (XmListGetSelectedPos( vsel->widgets.volumelist,
&pos_list, &pos_cnt))
......@@ -91,7 +91,7 @@ void WVsel::vsel_activate_ok (
if (vsel->vsel_bc_success != NULL)
sts = (vsel->vsel_bc_success) ( vsel, volume_ptr, pos_cnt);
XtFree( (char *) volume_ptr);
free( (char *) volume_ptr);
if ( ODD(sts))
{
......@@ -217,13 +217,13 @@ void WVsel::vsel_action_volumelist(
// The ok callback will be called later
return;
volume_ptr = (pwr_tVolumeId *) XtCalloc( 1, sizeof( pwr_tVolumeId));
volume_ptr = (pwr_tVolumeId *) calloc( 1, sizeof( pwr_tVolumeId));
*volume_ptr = vsel->volumes[ data->item_position - 1];
if (vsel->vsel_bc_success != NULL)
sts = (vsel->vsel_bc_success) ( vsel, volume_ptr, 1);
XtFree( (char *) volume_ptr);
free( (char *) volume_ptr);
if ( ODD(sts))
{
......
......@@ -151,7 +151,7 @@ int WAttNav::check_attr( int *multiline, brow_tObject *node,
sts = item->get_value( (char **)&p);
wnav_attrvalue_to_string( ldhses, item->type_id, p, init_value,
&len);
XtFree( p);
free( p);
*size = item->size;
if ( item->type_id == pwr_eType_Text)
*multiline = 1;
......@@ -173,7 +173,7 @@ int WAttNav::check_attr( int *multiline, brow_tObject *node,
sts = ((WItemObjectName *)base_item)->get_value( &p);
if ( ODD(sts)) {
strcpy( name, p);
XtFree( p);
free( p);
}
else
strcpy( name, "");
......@@ -820,7 +820,7 @@ int WAttNav::object_attr()
attr_exist = 1;
}
}
XtFree((char *) bodydef);
free((char *) bodydef);
}
brow_ResetNodraw( brow->ctx);
brow_Redraw( brow->ctx, 0);
......@@ -977,7 +977,7 @@ int WAttNav::set_attr_value( brow_tObject node, char *name, char *value_str)
memcpy( value + item->element * item->size, buff, item->size);
sts = ldh_SetObjectPar( ldhses, item->objid, item->body,
item->attr, value, size);
XtFree( (char *)value);
free( (char *)value);
item->update();
}
......
......@@ -147,7 +147,7 @@ void Wda::change_value( int set_focus)
}
if ( value)
XtFree( value);
free( value);
message( ' ', "");
if ( set_focus)
......@@ -580,7 +580,7 @@ void Wda::open_attr_dialog()
for ( j = 0; j < rows; j++)
attr_cnt++;
XtFree((char *) bodydef);
free((char *) bodydef);
}
attr_vect = (char (*)[80]) calloc( attr_cnt + 1, 80);
......@@ -602,7 +602,7 @@ void Wda::open_attr_dialog()
for ( j = 0; j < rows; j++)
strcpy( attr_vect[attr_cnt++], bodydef[j].ParName);
XtFree((char *) bodydef);
free((char *) bodydef);
}
strcpy( attr_vect[attr_cnt], "");
......@@ -646,11 +646,11 @@ int Wda::next_attr()
else if ( get_next) {
strcpy( attribute, bodydef[j].ParName);
sts = ((WdaNav *)wdanav)->update( objid, classid, attribute);
XtFree((char *) bodydef);
free((char *) bodydef);
return WDA__SUCCESS;
}
}
XtFree((char *) bodydef);
free((char *) bodydef);
}
return WDA__NONEXTATTR;
}
......@@ -689,19 +689,19 @@ int Wda::prev_attr()
if ( cdh_NoCaseStrcmp( attribute, bodydef[j].ParName) == 0) {
if ( strcmp( prev_attr, "") == 0) {
// get_last = 1;
XtFree((char *) bodydef);
free((char *) bodydef);
return WDA__NOPREVATTR;
}
else {
strcpy( attribute, prev_attr);
sts = ((WdaNav *)wdanav)->update( objid, classid, attribute);
XtFree((char *) bodydef);
free((char *) bodydef);
return WDA__SUCCESS;
}
}
strcpy( prev_attr, bodydef[j].ParName);
}
XtFree((char *) bodydef);
free((char *) bodydef);
}
if ( get_last && strcmp( prev_attr, "") != 0) {
......
......@@ -698,7 +698,7 @@ int WdaNav::get_attr()
if ( found)
break;
XtFree((char *) bodydef);
free((char *) bodydef);
}
if ( !found) {
......@@ -707,14 +707,14 @@ int WdaNav::get_attr()
}
if ( bodydef[j].Par->Output.Info.Type == pwr_eType_Buffer) {
XtFree((char *) bodydef);
free((char *) bodydef);
brow_ResetNodraw( brow->ctx);
return WDA__ATTRINVALID;
}
if ( bodydef[j].Par->Output.Info.Flags & PWR_MASK_ARRAY ) {
if ( bodydef[j].Par->Output.Info.Flags & PWR_MASK_INVISIBLE ) {
XtFree((char *) bodydef);
free((char *) bodydef);
brow_ResetNodraw( brow->ctx);
return WDA__ATTRINVISIBLE;
}
......@@ -728,7 +728,7 @@ int WdaNav::get_attr()
(void *)this, (void *) &bodydef[j], (void *) body,
NULL, NULL);
XtFree((char *) bodydef);
free((char *) bodydef);
brow_ResetNodraw( brow->ctx);
brow_Redraw( brow->ctx, 0);
......@@ -996,7 +996,7 @@ int WdaNav::set_attr_value( brow_tObject node, char *name, char *value_str)
memcpy( value + item->element * item->size, buff, item->size);
sts = ldh_SetObjectPar( ldhses, item->objid, item->body,
item->attr, value, size);
XtFree( (char *)value);
free( (char *)value);
item->update();
}
......
......@@ -737,7 +737,7 @@ int WNav::set_attr_value( brow_tObject node, pwr_tObjid objid, char *value_str)
memcpy( value + item->element * item->size, buff, item->size);
sts = ldh_SetObjectPar( ldhses, item->objid, item->body,
item->attr, value, size);
XtFree( (char *)value);
free( (char *)value);
}
return sts;
}
......@@ -808,7 +808,7 @@ int WNav::check_attr_value( brow_tObject node, int *multiline,
sts = item->get_value( (char **)&p);
wnav_attrvalue_to_string( ldhses, item->type_id, p, init_value,
&len);
XtFree( p);
free( p);
*size = item->size;
if ( item->type_id == pwr_eType_Text)
*multiline = 1;
......@@ -831,7 +831,7 @@ int WNav::check_attr_value( brow_tObject node, int *multiline,
sts = item->get_value( (char **)&p);
wnav_attrvalue_to_string( ldhses, item->type_id, p, init_value,
&len);
XtFree( p);
free( p);
*size = item->size;
if ( item->type_id == pwr_eType_Text)
*multiline = 1;
......@@ -850,7 +850,7 @@ int WNav::check_attr_value( brow_tObject node, int *multiline,
sts = ((WItemObjectName *)base_item)->get_value( &p);
if ( ODD(sts)) {
strcpy( name, p);
XtFree( p);
free( p);
}
else
strcpy( name, "");
......
......@@ -113,7 +113,7 @@ WItemObject::WItemObject( WNav *wnav, pwr_tObjid item_objid,
if ( ODD(sts))
{
brow_SetAnnotation( node, next_annot++, descr, strlen(descr));
XtFree( descr);
free( descr);
}
}
if ( wnav->gbl.show_alias && classid == pwr_eClass_Alias)
......@@ -129,7 +129,7 @@ WItemObject::WItemObject( WNav *wnav, pwr_tObjid item_objid,
alias_name, sizeof(alias_name), &size);
if ( EVEN(sts))
strcpy( alias_name, "-");
XtFree((char *) ref_object);
free((char *) ref_object);
brow_SetAnnotation( node, next_annot++, alias_name, strlen(alias_name));
}
}
......@@ -466,7 +466,7 @@ int WItemBaseObject::open_attributes( WNav *wnav, double x, double y)
attr_exist = 1;
}
}
XtFree((char *) bodydef);
free((char *) bodydef);
}
if ( attr_exist && !is_root)
......@@ -860,12 +860,12 @@ int WItemObjectName::get_value( char **value)
int size = 120;
int sts;
segname = XtMalloc( size);
segname = (char *) malloc( size);
sts = ldh_ObjidToName( ldhses, objid, ldh_eName_Object,
segname, size, &size);
if ( EVEN(sts))
{
XtFree( segname);
free( segname);
return sts;
}
*value = segname;
......@@ -1300,7 +1300,7 @@ int WItemAttr::update()
}
brow_SetAnnotation( node, 1, buff, len);
XtFree( (char *)value);
free( (char *)value);
return WNAV__SUCCESS;
}
......@@ -1369,7 +1369,7 @@ int WItemAttrInput::update()
wnav_attrvalue_to_string( ldhses, type_id, value, &buff, &len);
brow_SetAnnotation( node, 1, buff, len);
XtFree( (char *)value);
free( (char *)value);
sts = ldh_GetObjectBuffer( ldhses, objid, "DevBody", "PlcNode", &eclass,
(char **)&plcnode, &psize);
......@@ -1387,7 +1387,7 @@ int WItemAttrInput::update()
else
brow_SetRadiobutton( node, 1, 0);
XtFree((char *)plcnode);
free((char *)plcnode);
return WNAV__SUCCESS;
}
......@@ -1438,7 +1438,7 @@ int WItemAttrInput::set_mask( int radio_button, int value)
brow_SetRadiobutton( node, 1, 0);
}
XtFree((char *)plcnode);
free((char *)plcnode);
return WNAV__SUCCESS;
}
......@@ -1506,7 +1506,7 @@ int WItemAttrInputF::update()
wnav_attrvalue_to_string( ldhses, type_id, value, &buff, &len);
brow_SetAnnotation( node, 1, buff, len);
XtFree( (char *)value);
free( (char *)value);
sts = ldh_GetObjectBuffer( ldhses, objid, "DevBody", "PlcNode", &eclass,
(char **)&plcnode, &psize);
......@@ -1518,7 +1518,7 @@ int WItemAttrInputF::update()
else
brow_SetRadiobutton( node, 0, 0);
XtFree((char *)plcnode);
free((char *)plcnode);
return WNAV__SUCCESS;
}
......@@ -1555,7 +1555,7 @@ int WItemAttrInputF::set_mask( int radio_button, int value)
else
brow_SetRadiobutton( node, 0, 0);
}
XtFree((char *)plcnode);
free((char *)plcnode);
return WNAV__SUCCESS;
}
......@@ -1623,7 +1623,7 @@ int WItemAttrInputInv::update()
wnav_attrvalue_to_string( ldhses, type_id, value, &buff, &len);
brow_SetAnnotation( node, 1, buff, len);
XtFree( (char *)value);
free( (char *)value);
sts = ldh_GetObjectBuffer( ldhses, objid, "DevBody", "PlcNode", &eclass,
(char **)&plcnode, &psize);
......@@ -1635,7 +1635,7 @@ int WItemAttrInputInv::update()
else
brow_SetRadiobutton( node, 0, 0);
XtFree((char *)plcnode);
free((char *)plcnode);
return WNAV__SUCCESS;
}
......@@ -1672,7 +1672,7 @@ int WItemAttrInputInv::set_mask( int radio_button, int value)
else
brow_SetRadiobutton( node, 0, 0);
}
XtFree((char *)plcnode);
free((char *)plcnode);
return WNAV__SUCCESS;
}
......@@ -1740,7 +1740,7 @@ int WItemAttrOutput::update()
wnav_attrvalue_to_string( ldhses, type_id, value, &buff, &len);
brow_SetAnnotation( node, 1, buff, len);
XtFree( (char *)value);
free( (char *)value);
sts = ldh_GetObjectBuffer( ldhses, objid, "DevBody", "PlcNode", &eclass,
(char **)&plcnode, &psize);
......@@ -1752,7 +1752,7 @@ int WItemAttrOutput::update()
else
brow_SetRadiobutton( node, 0, 0);
XtFree((char *)plcnode);
free((char *)plcnode);
return WNAV__SUCCESS;
}
......@@ -1789,7 +1789,7 @@ int WItemAttrOutput::set_mask( int radio_button, int value)
else
brow_SetRadiobutton( node, 0, 0);
XtFree((char *)plcnode);
free((char *)plcnode);
}
return WNAV__SUCCESS;
......@@ -1939,7 +1939,7 @@ int WItemAttrArrayOutput::update()
else
brow_SetRadiobutton( node, 0, 0);
XtFree((char *)plcnode);
free((char *)plcnode);
return WNAV__SUCCESS;
}
......@@ -1976,7 +1976,7 @@ int WItemAttrArrayOutput::set_mask( int radio_button, int value)
else
brow_SetRadiobutton( node, 0, 0);
XtFree((char *)plcnode);
free((char *)plcnode);
}
return WNAV__SUCCESS;
......@@ -2102,9 +2102,9 @@ int WItemAttrArrayElem::get_value( char **value)
attr, &attr_value, &psize);
if ( EVEN(sts)) return sts;
*value = (char *) XtMalloc( size);
*value = (char *) malloc( size);
memcpy( *value, attr_value + offset, size);
XtFree( attr_value);
free( attr_value);
return WNAV__SUCCESS;
}
......@@ -2261,7 +2261,7 @@ int WItemAttrArrayElem::update()
}
brow_SetAnnotation( node, 1, buff, len);
XtFree( (char *)value);
free( (char *)value);
return WNAV__SUCCESS;
}
......@@ -2325,9 +2325,9 @@ int WItemEnum::update()
else
brow_SetRadiobutton( node, 0, 0);
if ( !is_element)
XtFree( (char *)value);
free( (char *)value);
else
XtFree( buf);
free( buf);
return WNAV__SUCCESS;
}
......@@ -2360,7 +2360,7 @@ int WItemEnum::set()
if ( EVEN(sts)) return sts;
// Warning!! the item will be deleted here by the ldh backcall
XtFree( buf);
free( buf);
}
if ( !ldh_cb_used)
......@@ -2451,9 +2451,9 @@ int WItemMask::update()
else
brow_SetRadiobutton( node, 0, 0);
if ( !is_element)
XtFree( (char *)value);
free( (char *)value);
else
XtFree( buf);
free( buf);
return WNAV__SUCCESS;
}
......@@ -2511,9 +2511,9 @@ int WItemMask::set( int set_value)
}
if ( !is_elem)
XtFree( (char *)value);
free( (char *)value);
else
XtFree( buf);
free( buf);
if ( !ldh_cb_used)
{
......
......@@ -1890,7 +1890,7 @@ static void wtt_activate_openge( Widget w, Wtt *wtt, XmAnyCallbackStruct *data)
if ( EVEN(sts)) break;
cdh_ToLower( graph_name, action);
XtFree( (char *)action);
free( (char *)action);
}
else if ( classid == pwr_cClass_WebGraph) {
sts = ldh_GetObjectPar( wtt->ldhses, attrref.Objid, "RtBody",
......@@ -1900,7 +1900,7 @@ static void wtt_activate_openge( Widget w, Wtt *wtt, XmAnyCallbackStruct *data)
cdh_ToLower( graph_name, action);
if ( strcmp( graph_name, "") != 0 && strstr( graph_name, ".pwg") == 0)
strcat( graph_name, ".pwg");
XtFree( (char *)action);
free( (char *)action);
}
else
break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment