On 02/18/2015 05:53 PM, Robbie King (robking) wrote:
Hey Mike (and everyone else),

I noticed this code is replicated throughout the patch:

        cos_shm = odp_shm_lookup("shm_odp_cos_tbl");
        if (cos_shm == ODP_SHM_INVALID)
                return -1;
        ret = odp_shm_free(cos_shm);

As I was looking to make the changes we discussed (continue
on versus returning -1) it seemed instead of replicating
even more code it would be better to have some cleaner way
of doing this.

One possibility is to simply nest the calls (shm_free just
returns -1 if passed SHM_INVALID).

       ret = odp_shm_free(odp_shm_lookup("shm_odp_cos_tbl"));

Another option is to create a helper function, something like:

       ret = odp_shm_free_by_name("shm_odp_cos_tbl");

If the helper is the way to go, then it could either be internal
or published API.  Any thoughts on the "correct solution"?

1) nested calls
2) internal API
3) published API

I prefer a forth option :)
Save allocated odp_shm_t handle and don't lookup it.

_______________________________________________
lng-odp mailing list
[email protected]
http://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to